From 745d226aa12c0dc7c6f2aa608d473559e02dc761 Mon Sep 17 00:00:00 2001 From: Thomas Stephen Lee Date: Wed, 11 Jan 2017 15:23:46 +0530 Subject: fixed mail function --- code.inc | 46 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/code.inc b/code.inc index dd1ebd5..2966162 100755 --- a/code.inc +++ b/code.inc @@ -422,10 +422,22 @@ function upload_examples_form_submit($form, &$form_state) } //$_FILES['files']['name'] as $file_form_name => $file_name drupal_set_message('Example uploaded successfully.', 'status'); /* sending email */ - $email_to = $user->mail; + $email_to = $user->mail; + $from = variable_get('textbook_companion_from_email', ''); + $bcc = variable_get('textbook_companion_bcc_emails', ''); + $cc = variable_get('textbook_companion_cc_emails', ''); $params['example_uploaded']['example_id'] = $example_id; - $params['example_uploaded']['user_id'] = $user->uid; - if (!drupal_mail('textbook_companion', 'example_uploaded', $email_to, language_default(), $params, variable_get('textbook_companion_from_email', NULL), TRUE)) + $params['example_uploaded']['user_id'] = $user->uid; + $params['example_uploaded']['headers'] = array( + 'From' => $from, + 'MIME-Version' => '1.0', + 'Content-Type' => 'text/plain; charset=UTF-8; format=flowed; delsp=yes', + 'Content-Transfer-Encoding' => '8Bit', + 'X-Mailer' => 'Drupal', + 'Cc' => $cc, + 'Bcc' => $bcc + ); + if (!drupal_mail('textbook_companion', 'example_uploaded', $email_to, language_default(), $params, $from, TRUE)) drupal_set_message('Error sending email message.', 'error'); drupal_goto('textbook-companion/code'); } @@ -501,14 +513,26 @@ function _upload_examples_delete() if (delete_example($example_data->id)) { drupal_set_message('Example deleted.', 'status'); /* sending email */ - $email_to = $user->mail; - $params['example_deleted_user']['book_title'] = $preference_data->book; - $params['example_deleted_user']['chapter_title'] = $chapter_data->name; - $params['example_deleted_user']['example_number'] = $example_data->number; - $params['example_deleted_user']['example_caption'] = $example_data->caption; - $params['example_deleted_user']['user_id'] = $user->uid; - if (!drupal_mail('textbook_companion', 'example_deleted_user', $email_to, language_default(), $params, variable_get('textbook_companion_from_email', NULL), TRUE)) - drupal_set_message('Error sending email message.', 'error'); + $email_to = $user->mail; + $from = variable_get('textbook_companion_from_email', ''); + $bcc = variable_get('textbook_companion_emails', ''); + $cc = variable_get('textbook_companion_cc_emails', ''); + $params['example_deleted_user']['book_title'] = $preference_data->book; + $params['example_deleted_user']['chapter_title'] = $chapter_data->name; + $params['example_deleted_user']['example_number'] = $example_data->number; + $params['example_deleted_user']['example_caption'] = $example_data->caption; + $params['example_deleted_user']['user_id'] = $user->uid; + $params['example_deleted_user']['headers'] = array( + 'From' => $from, + 'MIME-Version' => '1.0', + 'Content-Type' => 'text/plain; charset=UTF-8; format=flowed; delsp=yes', + 'Content-Transfer-Encoding' => '8Bit', + 'X-Mailer' => 'Drupal', + 'Cc' => $cc, + 'Bcc' => $bcc + ); + if (!drupal_mail('textbook_companion', 'example_deleted_user', $email_to, language_default(), $params, $from, TRUE)) + drupal_set_message('Error sending email message.', 'error'); } //delete_example($example_data->id) else { drupal_set_message('Error deleting example.', 'status'); -- cgit