Send mail + attachment with PHPmailer


/ Published in: PHP
Save to your folder(s)

http://phpmailer.worxware.com/index.php?pg=methods


Copy this code and paste it in your HTML
  1. require_once PATH . '/include/phpmailer/class.phpmailer.php';
  2.  
  3. $html_body = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4. <html>
  5. <head>
  6. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  7. <!-- Facebook sharing information tags -->
  8. <meta property="og:title" content="EMAIL_SUBJECT" />
  9. <title>EMAIL_SUBJECT</title>
  10. </head>
  11. <body>MAIL_TEXT</body>
  12. </html>';
  13.  
  14. $text_body = 'MAIL_TEXT';
  15.  
  16. $mailer = new PHPMailer();
  17. $mailer->From = 'FROM_EMAIL';
  18. $mailer->FromName = 'FROM_NAME';
  19. $mailer->Subject = 'SUBJECT';
  20. $mailer->ContentType = 'text/html';
  21. $mailer->CharSet = 'utf-8';
  22. $mailer->Priority = 2;
  23. $mailer->Body = $html_body;
  24. $mailer->AltBody = $text_body;
  25. $mailer->IsHTML(true);
  26. $mailer->AddAddress(TO_EMAIL);
  27. $mailer->AddReplyTo('REPLY_TO_EMAIL');
  28. $mailer->AddAttachment('FILE_PATH', 'FILE_NAME');
  29.  
  30. if ($mailer->Send()) {
  31. echo 'Mail sent';
  32. } else {
  33. echo 'Mail error';
  34. }

URL: http://phpmailer.worxware.com/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.