Using the mail-sending interface to invoke the process in the PHP programming language

Source: Internet
Author: User

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

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.