The process of how to use the SMTP class to send mail, for many technical beginners are not very understanding, usually in the programming process encountered a lot of problems, some even do not know the interface of the call process, then in this case, Let's talk about the process of how the PHP programming language uses mail-sending interface calls. The implementation code and comments are as follows:
1. Open the php.ini, locate the Extension=php_openssl.dll, remove the preceding semicolon, and restart the server. If this configuration is turned on, skip this step.
2. Send mail code
$MailServer = "smtp.163.com"; SMTP server (unless 163 mailboxes are configured for the corresponding SMTP server)
$MailPort = 25; SMTP Server port
$smtpMail = "[email protected]"; User mailboxes for the SMTP server
$smtpuser = "xxxxx"; The user account for the SMTP server (does not include the mailbox suffix @163.com, etc.)
$smtppass = "Email Password or authorization code"; The user password or authorization code of the SMTP server (sometimes set to the mailbox password is also available, if not available, set to the authorization code)
$email = Trim ($email);//e-mail address to be sent
The associated SMTP class, which creates a $smtp object, is a true representation of the use of authentication, otherwise no authentication is used.
Require_once './index/modules/home/action/smtp.class.php ';
$SMTP = new SMTP ($MailServer, $MailPort, $smtpuser, $smtppass, true);
$SMTP->debug = false;//Debug Phase writes true to see the error message, the deployment stage is set to False
$mailType = "HTML"; Letter type, text: text; Web page: HTML
$email = $email; Recipient mailbox
$emailTitle = ""; Message subject
$emailTitle = "=? UTF-8? B? ". Base64_encode ($emailTitle). "? = ";//Sometimes the subject of the message will appear garbled, this time add this line code
$emailBody = "";//message content
$smtp->sendmail ($email, $smtpMail, $emailTitle, $emailBody, $mailType);
The above is for everyone to explain the call process through the mail send interface, understanding of the technical staff can go to try, if there are doubts about the place can be in the comments below consulting us.
This article by the Professional app development company Brigitte Xuan Science and technology release, is the original content, interested technical staff if need to reprint, please specify the author and source!
Using the mail-sending interface to invoke the process in the PHP programming language