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.