How to properly use the PHP Swift time-limit email relaxation function

Source: Internet
Author: User
Tags email account ssl connection

We know that

PHP Swift code example 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 an smtp connection. The smtp address and port used to send emails
  8. $ Smtp = new Swift_Connection_SMTP
    ('Smtp .sina.com ', 25 );
  9. // Set the email account used to send emails
  10. $ Smtp-> setUsername ('demo _ send@sina.com ');
  11. // Set the logon password of the sender's email address
  12. $ Smtp-> setPassword ('1qaz2wsx ');
  13. // Add ssl connection support. If this option is not enabled, it is sent to gmail.
    If this option is enabled, the mailbox that requires an ssl connection will fail.
    The email sending speed will be affected.
  14. If (stripos ($ receive_mail, "@ gmail.com ")! = False ){
  15. $ Smtp-> attachAuthenticator (new
    Swift_Authenticator_LOGIN ());
  16. }
  17. $ Swift = new Swift ($ smtp );
  18. // Mail title
  19. $ Title = "you have received a new resume for applying for a job as a php programmer ";
  20. // Body of the email
  21. $ Content = "Postmaster, hello! You have received a new resume,
    Apply for a job as a 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': 'failed ';
  24. ?>

We hope that the above PHP Swift usage will be helpful to friends who need it.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.