Home  >  Article  >  Backend Development  >  How to correctly use the relaxation function of PHP Swift time-limited email_PHP Tutorial

How to correctly use the relaxation function of PHP Swift time-limited email_PHP Tutorial

WBOY
WBOYOriginal
2016-07-15 13:31:53995browse

We know that when using

PHP Swift to implement specific code examples for sending emails:

  1. < ?php
  2. include_once ("Swift.php");
  3. include_once ("Swift/Connection /SMTP.php");
  4. include_once ("Swift/Authenticator/LOGIN.php");
  5. //Recipient’s Address
  6. $receive_mail="demo_receive@gmail.com";
  7. // Create smtp connection, due to the email smtp address and port for sending emails
  8. $smtp = new Swift_Connection_SMTP
    ('smtp.sina.com', 25);
  9. // Set for sending emails Email account
  10. $smtp->setUsername('demo_send@sina.com');
  11. //Set the email login password for the outbox
  12. $smtp->setPassword('1qaz2wsx') ;
  13. //Add ssl connection support. Without this item, sending to emails that require ssl connection such as gmail
    will fail, but turning this option
    will affect Email sending speed
  14. if(stripos($receive_mail,"@gmail.com")!==false){
  15. $smtp ->attachAuthenticator(new
    Swift_Authenticator_LOGIN());
  16. }
  17. $swift = new Swift($smtp);
  18. //Email Title
  19. $title="You have received a new resume for a job as a PHP programmer Position";
  20. //Email text
  21. $content="Hello, administrator! You have received a new resume,
    Apply for the position of php programmer...< 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')))
    ?'Success':'Failure';
  24. ?>

I hope the above introduction to how to use PHP Swift can be helpful to friends who need it again


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/446173.htmlTechArticleWe know that there are specific code examples for using PHP Swift to send emails: ?php include_once(Swift.php); include_once(Swift/Connection/SMTP.php); include_once(Swift/Authenticator...
Statement:
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