edit-icon download-icon

SMTP-PHP

Last Updated: Dec 18, 2017

The following example shows how to send an email through SMTP using PHP.

  1. <?php
  2. require 'email.class.php';
  3. $mailto='***';
  4. $mailsubject="Test mail";
  5. $mailbody='Here is the mail content';
  6. $smtpserver = "smtpdm.aliyun.com";
  7. $smtpserverport = 25;
  8. $smtpusermail = "***";
  9. $smtpuser = "***";
  10. $smtppass = "***";
  11. $mailsubject = "=?UTF-8?B?" . base64_encode($mailsubject) . "?=";
  12. $mailtype = "HTML";
  13. $smtp = new smtp($smtpserver, $smtpserverport, true, $smtpuser, $smtppass);
  14. $smtp->debug = false;
  15. $smtp->sendmail($mailto, $smtpusermail, $mailsubject, $mailbody, $mailtype);

Note: email.class.php is an external dependency which you must obtain by yourself.

Thank you! We've received your feedback.