Home > php教程 > php手册 > body text

怎样正确使用PHP Swift时限邮件的放松功能

WBOY
Release: 2016-06-13 11:09:13
Original
1638 people have browsed it

我们知道,在使用

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程序员的职位......"
    ;  
  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使用方法,能够对又需要的朋友有所帮助。


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!