In php, the email sending function mail () is provided. We can use this function to send emails directly. Below I will introduce some common email sending instances. The simplest is the mail function.
Example
The Code is as follows: |
Copy code |
Function send_mail ($ from, $ to, $ subject, $ message) { If ($ from = "") { $ From = 'Recalling the future '; // Sender address } $ Headers = 'mime-Version: 100'. "rn "; $ Headers. = 'content-type: text/html; charset = gb2312 '. "rn "; $ Headers. = 'from: '. $ From. "rn "; Mail ($ to, $ subject, $ message, $ headers ); } ?> |
Prompt
The program to be used is defined by the configuration settings in the php. ini file. The behavior of the mail function is affected by php. ini. We must configure it first.
The default name description can be changed.
SMTP "localhost" for Windows: the DNS name or IP address of the SMTP server. PHP_INI_ALL
Smtp_port "25" for Windows: SMTP segment slogan. Available from PHP 4.3. PHP_INI_ALL
Sendmail_from NULL for Windows: Specifies the "from" address used in emails sent from PHP. PHP_INI_ALL
Sendmail_path NULL dedicated for Unix systems: Specifies the sendmail program path (usually/usr/sbin/sendmail or
/Usr/lib/sendmail) PHP_INI_SYSTEM