I have been using a third-party email system to send emails, such as QQ
I have been using a third-party email system to send emails, such as QQ
Configuration
To do well, you must first sharpen your tools. First, we will take windows as an example to describe how to configure local mail.
Download the attachment sendmail.zip
-Decompress the package to any path, modify sendmail. ini, and modify the following information as needed.
The Code is as follows:
[Sendmail]
Smtp_server = smtp.qq.com
Smtp_port = 25
Error_logfile = error. log
Debug_logfile = debug. log
Auth_username = *** @ qq.com
Auth_password = ***
Force_sender = *** @ qq.com
-Php. ini
[Mail function]
SMTP = smtp.qq.com
Smtp_port = 25
Sendmail_from = *** @ qq.com
Sendmail_path = "D:/sendmail/sendmail.exe-t-I"
Mail. add_x_header = On
Note:
Currently, the test is successful only by qq. If 163 is unsuccessful, it may be that he has a filtering system that can be successfully sent to gmail.
Syntax
The Code is as follows:
Mail (to, subject, message, headers, parameters)
Definition and usage
The mail () function allows you to send emails directly from scripts.
If the mail is successfully received, true is returned; otherwise, false is returned.
Description
In messages specified by the message parameter, rows must be separated by an LF (\ n. Each line cannot exceed 70 characters.
(IN Windows) when PHP is directly connected to the SMTP server, if a full stop is found at the beginning of a line, it will be deleted. To avoid this problem, replace a single period with two periods.
The Code is as follows:
$ Text = str_replace ("\ n.", "\ n ..", $ text );
?>
Tips and comments
Note: you need to keep in mind that the mail delivery is accepted and does not mean that the mail has reached the planned destination.
Example
The following is an official example of sending HTML emails.
The Code is as follows:
$ To = "somebody@example.com, somebodyelse@example.com ";
$ Subject = "HTML email ";
$ Message ="
HTML email
This email contains HTML Tags!
Firstname |
Lastname |
John |
Doe |
";
// When sending an HTML email, always set content-type
$ Headers = "MIME-Version: 1.0". "\ r \ n ";
$ Headers. = "Content-type: text/html; charset = UTF-8". "\ r \ n ";
// More headers
$ Headers. = 'from: '. "\ R \ n ";
$ Headers. = 'HTTP: myboss@example.com '. "\ r \ n ";
Mail ($ to, $ subject, $ message, $ headers );
?>