欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

在PHP代码中发送邮件的简单示例

程序员文章站 2022-04-25 16:37:22
...
  1. include("class.phpmailer.php");
  2. $mail = new PHPMailer();
  3. $mail->From = 'your email address@.com';
  4. $mail->FromName = 'HTML Blog';
  5. $mail->Host = 'host name';
  6. $mail->Mailer = 'smtp';
  7. $mail->Subject = 'subject';
  8. $mail->IsHTML(true);
  9. $body = 'Hello
    How are you ?';
  10. $textBody = 'Hello, how are you ?';
  11. $mail->Body = $body;
  12. $mail->AltBody = $textBody;
  13. $mail->AddAddress('reciepents full email address');
  14. if(!$mail->Send())
  15. echo 'There has been a mail error !';
复制代码

发送邮件, PHP