diff options
author | prashantsinalkar | 2018-10-24 16:43:23 +0530 |
---|---|---|
committer | prashantsinalkar | 2018-10-24 16:43:23 +0530 |
commit | fec1b0036107203daabf5c55c2a3832074d8146b (patch) | |
tree | c261f7939228c91382fe56e847e43e43e0ebfd58 | |
parent | e8e234944bae61a5005de6eafb33176639006001 (diff) | |
download | osdag_workshop_booking-fec1b0036107203daabf5c55c2a3832074d8146b.tar.gz osdag_workshop_booking-fec1b0036107203daabf5c55c2a3832074d8146b.tar.bz2 osdag_workshop_booking-fec1b0036107203daabf5c55c2a3832074d8146b.zip |
updated the mail temlpate for html mail
-rw-r--r-- | workshop_registration_email.inc | 122 |
1 files changed, 88 insertions, 34 deletions
diff --git a/workshop_registration_email.inc b/workshop_registration_email.inc index 6b9df1c..8cc4500 100644 --- a/workshop_registration_email.inc +++ b/workshop_registration_email.inc @@ -2,6 +2,57 @@ /** * Implementation of hook_mail(). */ + /** + * Modify the drupal mail system to send HTML emails. + */ +class WorkshopMailSystem implements MailSystemInterface { + /** + * Concatenate and wrap the e-mail body for plain-text mails. + * + * @param array $message + * A message array, as described in hook_mail_alter(). + * + * @return array + * The formatted $message. + */ + public function format(array $message) { + $message['body'] = implode("\n\n", $message['body']); + return $message; + } + + /** + * Send an e-mail message, using Drupal variables and default settings. + * + * @see http://php.net/manual/en/function.mail.php + * @see drupal_mail() + * + * @param array $message + * A message array, as described in hook_mail_alter(). + * + * @return bool + * TRUE if the mail was successfully accepted, otherwise FALSE. + */ + public function mail(array $message) { + $mimeheaders = array(); + foreach ($message['headers'] as $name => $value) { + $mimeheaders[] = $name . ': ' . mime_header_encode($value); + } + $line_endings = variable_get('mail_line_endings', MAIL_LINE_ENDINGS); + return mail( + $message['to'], + mime_header_encode($message['subject']), + // Note: e-mail uses CRLF for line-endings. PHP's API requires LF + // on Unix and CRLF on Windows. Drupal automatically guesses the + // line-ending format appropriate for your system. If you need to + // override this, adjust $conf['mail_line_endings'] in settings.php. + preg_replace('@\r?\n@', $line_endings, $message['body']), + // For headers, PHP's API suggests that we use CRLF normally, + // but some MTAs incorrectly replace LF with CRLF. See #234403. + implode("\n", $mimeheaders) + ); + } +} + function osdag_workshop_booking_mail($key, &$message, $params) { global $user; @@ -10,8 +61,8 @@ function osdag_workshop_booking_mail($key, &$message, $params) { case 'proposal_received': /* initializing data */ - $proposal_q = db_query("SELECT * FROM {osdag_workshop_booking_proposal} WHERE id = %d LIMIT 1", $params['proposal_received']['proposal_id']); - $proposal_data = db_fetch_object($proposal_q); + $proposal_q = db_query("SELECT * FROM {osdag_workshop_booking_proposal} WHERE id = :proposal_id LIMIT 1", array( ':proposal_id' => $params['proposal_received']['proposal_id'])); + $proposal_data = $proposal_q->fetchObject(); $full_name = $proposal_data->title .' ' . $proposal_data->fname . ' ' . $proposal_data->lname; $workshop_type = $proposal_data->workshop_type; $institute_company = $proposal_data->institute_company; @@ -31,23 +82,25 @@ function osdag_workshop_booking_mail($key, &$message, $params) 'body' => t(' Dear '. $full_name .', -Thank you for showing your interest to organize a '. $workshop_type .' on +<p>Thank you for showing your interest to organize a '. $workshop_type .' on structural steel design and detailing using Open Steel Design and Graphics - (Osdag) at '. $institute_company .'on '. $suggested_date .' + (Osdag) at '. $institute_company .' on '. $suggested_date .'</p> -Your request has been received and is awaiting for approval by PI of Osdag. -You will get a confirmation email on approval/disapproval/re-scheduling of the - training workshop within 15 days. +<p>Your request has been received and is awaiting for approval by PI of Osdag. + You will get a confirmation email on approval/disapproval/re-scheduling of the + training workshop within 15 days.</p> -Please note: Unless you get a confirmation email for this workshop with the list - of instructions, your workshop shall be on the waiting list. +<p>Please note: Unless you get a confirmation email for this workshop with the + list of instructions, your workshop shall be on the waiting list.</p> Thank you! -Best Regards, -Team Osdag, -FOSSEE, IIT Bombay. +Best Regards,<br> +Team Osdag,<br> +FOSSEE, IIT Bombay.<br> + +<p><center><h6>This is an automated system generated email.</h6></center></p> ', array( '!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name @@ -58,8 +111,8 @@ FOSSEE, IIT Bombay. break; case 'proposal_approved': /* initializing data */ - $proposal_q = db_query("SELECT * FROM {osdag_workshop_booking_proposal} WHERE id = %d LIMIT 1", $params['proposal_approved']['proposal_id']); - $proposal_data = db_fetch_object($proposal_q); + $proposal_q = db_query("SELECT * FROM {osdag_workshop_booking_proposal} WHERE id = :proposal_id LIMIT 1", array(':proposal_id' => $params['proposal_approved']['proposal_id'])); + $proposal_data = $proposal_q->fetchObject(); $full_name = $proposal_data->title .' ' . $proposal_data->fname . ' ' . $proposal_data->lname; $workshop_type = $proposal_data->workshop_type; $institute_company = $proposal_data->institute_company; @@ -79,21 +132,22 @@ FOSSEE, IIT Bombay. 'body' => t(' Dear '. $full_name .', -Your request for organizing the training workshop has been approved by PI of - Osdag. - -The details of the workshop are as follows:'. -$Workshop type .' -Date: '. $suggested_date .' -Resource person: One resource person for every 25 participants, with a minimum - of 2. +<p>Your request for organizing the training workshop has been approved by PI of + Osdag.</p> -You will receive an email from team Osdag with detailed Instructions soon. +<p>The details of the workshop are as follows: +<ul> +<li>'. $workshop_type .'</li> +<li>Date: '. $suggested_date .'</li> +<li>Resource person: One resource person for every 25 participants, with a + minimum of 2.</li> +</ul> +You will receive an email from team Osdag with detailed Instructions soon.</p> -Thank you! +<p>Thank you!</p> -Best Regards, -Team Osdag, +Best Regards,<br> +Team Osdag,<br> FOSSEE, IIT Bombay. ', array( '!site_name' => variable_get('site_name', ''), @@ -105,8 +159,8 @@ FOSSEE, IIT Bombay. break; case 'proposal_disapproved': /* initializing data */ - $proposal_q = db_query("SELECT * FROM {osdag_workshop_booking_proposal} WHERE id = %d LIMIT 1", $params['proposal_disapproved']['proposal_id']); - $proposal_data = db_fetch_object($proposal_q); + $proposal_q = db_query("SELECT * FROM {osdag_workshop_booking_proposal} WHERE id = :proposal_id LIMIT 1", array(':proposal_id' => $params['proposal_disapproved']['proposal_id'])); + $proposal_data = $proposal_q->fetchObject(); $full_name = $proposal_data->title .' ' . $proposal_data->fname . ' ' . $proposal_data->lname; $workshop_type = $proposal_data->workshop_type; $institute_company = $proposal_data->institute_company; @@ -126,16 +180,16 @@ FOSSEE, IIT Bombay. 'body' => t(' Dear '. $full_name .', - -We regret to inform you that your request for organizing the training workshop - has been disapproved by PI of Osdag due to [reason] +<p>We regret to inform you that your request for organizing the training workshop has been disapproved by PI of Osdag due to '. $proposal_data->disapprove_message .'.</p> Thank you! -Best Regards, -Team Osdag, -FOSSEE, IIT Bombay.', array( +Best Regards,<br> +Team Osdag,<br> +FOSSEE, IIT Bombay.<br> +' +, array( '!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name ), array( |