PHP uses the SAE native mail class to implement various types of mail delivery methods _php Tips

Source: Internet
Author: User
Tags php programming php regular expression ssl connection

This example describes how PHP uses the SAE native mail class to implement various types of mail delivery methods. Share to everyone for your reference, specific as follows:

With the SAE all know, SAE all services, the number of mail service is the worst, from time to time mail will not be sent out. In particular, the enterprise Post Office, even Sina's own enterprise post Office have problems. Give the solution today.

Let's look at the demo shown in the SAE documentation:

$mail = new Saemail ();
$mail->setattach (Array (' My_photo ' => ' photo binary data ');/attachment Send method
$ret = $mail->quicksend (' to@sina.cn ', ' message header ', ' mail content ', ' smtpaccount@unknown.com ', ' Password ', ' smtp.unknown.com ', 25; Specifying SMTP and Ports

The SAE-given demo uses the Quicksend () method, which has been tested by me to be perfectly sent when using a non-enterprise post Office, and to a high letter rate. However, note that only SMTP 25 ports can not use SSL connection, do not know whether to open the wrong way, I hope expert advice.

But for the site, there is a separate domain name mailbox is very important, then the Enterprise Post Office will be useful. Simply using the Quicksend () method always sends a failure. So we're going to use the Send () method. The Send () method is slightly more complex:

1, set the Send parameter Setopt (), set this send parameter to the Quicksend () method is invalid, only to send () valid.

$mail = new Saemail ();
$mail->setopt (
  ' from ' => ' send mailbox ',
  ' to ' => trim ($to),//Receive Mailbox
  ' smtp_host ' => ' SMTP server ',
  ' Smtp_port ' =>,//port
  ' smtp_username ' => ' account full name ', ' Smtp_password ' => '
  password ',
  ' subject ' = > ' Subject ',
  ' content ' => ' contents ',
  ' content_type ' => ' HTML '//Send format, default is Text
        )
      ;
$ret = $mail->send ();

So, it can be. More parameters can be viewed in official documents.

Because this site is only a comment reply to the message prompts, so in Send () and no SSL test, there is a need to test their own.

This is the end, if you do not like the method, but also their own Baidu Third-party Mail class library, is also possible. After testing the letter and the receipt is probably within 3 seconds, can meet most of the needs.

More about PHP Interested readers can view the site topics: "PHP common Database Operation skills Summary", "PHP array" operation Skills Daquan, "PHP Sorting algorithm Summary", "PHP common traversal algorithm and skills summary", "PHP Data structure and algorithm tutorial", " PHP Programming algorithm Summary, "PHP Mathematical Calculation Skills Summary", "PHP Regular Expression Usage summary", "PHP operation and operator usage Summary" and "PHP string (String) Usage Summary"

I hope this article will help you with the PHP program design.

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.