当前位置:Gxlcms > PHP教程 > 怎样正确使用PHPSwift时限邮件的放松功能_PHP教程

怎样正确使用PHPSwift时限邮件的放松功能_PHP教程

时间:2021-07-01 10:21:17 帮助过:33人阅读

我们知道,在使用

PHP Swift实现邮件发送的具体代码示例:

  1. < ?php
  2. include_once ("Swift.php");
  3. include_once ("Swift/Connection/SMTP.php");
  4. include_once ("Swift/Authenticator/LOGIN.php");
  5. //收件人的地址
  6. $receive_mail="demo_receive@gmail.com";
  7. // 创建smtp连接,由于发送邮件的邮箱smtp地址和端口
  8. $smtp = new Swift_Connection_SMTP
    ('smtp.sina.com', 25);
  9. // 设置用于发送邮件的邮箱账号
  10. $smtp->setUsername('demo_send@sina.com');
  11. // 设置发件箱的邮箱登陆密码
  12. $smtp->setPassword('1qaz2wsx');
  13. //添加ssl连接支持,如果没此项,发送到gmail
    等需要ssl连接的邮箱就会失败,但是开启此选项
    会影响邮件发送的速度
  14. if(stripos($receive_mail,"@gmail.com")!==false){
  15. $smtp->attachAuthenticator(new
    Swift_Authenticator_LOGIN());
  16. }
  17. $swift = new Swift($smtp);
  18. //邮件标题
  19. $title="您收到一封新的求职简历,应聘php程序员的职位";
  20. //邮件正文
  21. $content="管理员,您好!您收到一封新的求职简历,
    应聘php程序员的职位......< br/>"
    ;
  22. $message = new Swift_Message
    ($title, $content, 'text/html', 'base64');
  23. echo ($swift->send( $message,
    $receive_mail, new Swift_Address
    ('demo_send@sina.com','demo_sender')))
    ?'成功':'失败';
  24. ?>

希望以上介绍的PHP Swift使用方法,能够对又需要的朋友有所帮助。


www.bkjia.comtruehttp://www.bkjia.com/PHPjc/446173.htmlTechArticle我们知道,在使用 PHP Swift实现邮件发送的具体代码示例: ?php include_once(Swift.php); include_once(Swift/Connection/SMTP.php); include_once(Swift/Authenticator...

人气教程排行