SMTP-Php

Last Updated: Aug 09, 2017

Send a mail via 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 should obtain by yourself. smtpuser =“Replace it with the complete sender address”.

Thank you! We've received your feedback.