From 8597bbd8311787c4315a8d586af7364543e0ae37 Mon Sep 17 00:00:00 2001
From: Sashi20
Date: Fri, 19 Feb 2021 12:39:37 +0530
Subject: Update function sending mail with attachment
---
xcos_tbc_external_review.module | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)
diff --git a/xcos_tbc_external_review.module b/xcos_tbc_external_review.module
index e6fa704..006d203 100755
--- a/xcos_tbc_external_review.module
+++ b/xcos_tbc_external_review.module
@@ -379,7 +379,6 @@ ini_set('display_startup_errors', TRUE);
$body = $message1;
$filename = basename($file);
$from = str_replace(array("\r", "\n"), '', $from); // to prevent email injection
- //var_dump($from);die;
$file_size = filesize($file);
$handle = fopen($file, "r");
$content = fread($handle, $file_size);
@@ -387,15 +386,14 @@ ini_set('display_startup_errors', TRUE);
$content = chunk_split(base64_encode($content));
$uid = md5(uniqid(time()));
$filename = basename($file);
- $eol = PHP_EOL;
- //var_dump($eol);die;
+ $eol = PHP_EOL;
// Basic headers
- $header = "From: " . $from . " <" . $from . ">" . $eol;
- $header .= "Reply-To: " . $from . $eol;
- $header .= "Cc:". $cc.$eol;
- $header .= "Bcc:". $bcc.$eol;
- $header .= "MIME-Version: 1.0"."\r\n";
- $header .= "Content-type: text/html; charset=iso-8859-1" ."\r\n";
+ $header = "From: ".$from." <".$from.">".$eol;
+ $header .= "Reply-To: ".$from.$eol;
+ $header .= "Cc:". $cc.$eol;
+ $header .= "Bcc:". $bcc.$eol;
+ $header .= "MIME-Version: 1.0\r\n";
+ $header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"";
// Put everything else in $message
$message = "--".$uid.$eol;
$message .= "Content-Type: text/html; charset=ISO-8859-1".$eol;
@@ -407,9 +405,8 @@ ini_set('display_startup_errors', TRUE);
$message .= "Content-Disposition: attachment; filename=\"".$filename."\"".$eol;
$message .= $content.$eol;
$message .= "--".$uid."--";
- //var_dump($to . ' ' . $message . ' ' . $subject . ' ' . $message . ' ' . $header);die;
+
return mail($to, $subject, $message, $header);
- //var_dump(xcos_send_mail($to, $subject, $message, $header));die;
}
/* external reviewer profile form,
save the data in {xcos_external_review_profile}
@@ -2184,7 +2181,7 @@ ini_set('display_startup_errors', TRUE);
$bcc = variable_get('xcos_tbc_external_review_bcc_emails', '');
$cc = variable_get('xcos_tbc_external_review_cc_emails', '');
- $subject = "Scilab Textbook Companion - {$review_no} Review";
+ $subject = "Xcos Textbook Companion - {$review_no} Review";
$message = "
Dear {$row->name}
Please find the attached file containing the list of errors found in your uploaded book:
--
cgit