Guest User

Untitled

a guest
May 24th, 2018
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. // To send HTML mail, the Content-type header must be set
  2. $headers = 'MIME-Version: 1.0' . "rn";
  3. $headers .= 'Content-type: text/html; charset=iso-8859-1' . "rn";
  4.  
  5. // Additional headers
  6. $headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "rn";
  7. $headers .= 'From: Birthday Reminder <birthday@example.com>' . "rn";
  8. $headers .= 'Cc: birthdayarchive@example.com' . "rn";
  9. $headers .= 'Bcc: birthdaycheck@example.com' . "rn";
  10.  
  11. // Mail it
  12. mail($to, $subject, $message, $headers);
  13.  
  14. // Setup recipients
  15. $to = 'johndoe@google.com' . ',' // comma separates multiple addresses
  16. $to .= 'janedoe@msn.com';
  17.  
  18. // subject
  19. $subject = 'PHP Email Script - Test Email';
  20.  
  21. // message (to use single quotes in the 'message' variable, supercede them with a back slash like this-->&nbsp; '
  22. $message = '
  23. <html>
  24. <head>
  25. <title>PHP Email Script</title>
  26. </head>
  27. <body>
  28. <p style="background: #ccc; width: 100%;">Test Email Script</p>
  29. </body>
  30. </html>
  31. ';
  32.  
  33.  
  34. // To send HTML mail, the Content-type header must be set
  35. $headers = 'MIME-Version: 1.0' . "rn";
  36. $headers .= 'Content-type: text/html; charset=iso-8859-1' . "rn";
  37.  
  38. // Additional headers
  39. $headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "rn";
  40. $headers .= 'From: Birthday Reminder <birthday@example.com>' . "rn";
  41. $headers .= 'Cc: birthdayarchive@example.com' . "rn";
  42. $headers .= 'Bcc: birthdaycheck@example.com' . "rn";
  43.  
  44. // Send the email
  45. mail($to, $subject, $message, $headers);
  46.  
  47. $email_templates = array('text/html' => 'email/html/' . $template . '.en.html.tpl',
  48. 'text/plain' => 'email/text/' . $template . '.en.txt.tpl');
  49.  
  50. foreach ($email_templates as $type => $file) {
  51. if ($email->template_exists($file)) {
  52. $message->attach(new Swift_Message_Part($email->fetch($file), $type));
  53. } elseif ($type == 'text/plain') {
  54. throw new Exception('Could not send email -- no text version was found');
  55. }
  56. }
Add Comment
Please, Sign In to add comment