PHP comes with the mailbox sending function mail(). We can use this function directly to send mails. Below I will introduce some commonly used mailbox sending examples. The simplest one is the mail function.
Example
The code is as follows |
Copy code |
代码如下 |
复制代码 |
function send_mail($from, $to, $subject, $message)
{
if ($from == "")
{
$from = '回忆未来 ';//发件人地址
}
$headers = 'MIME-Version: 1.0' . "rn";
$headers .= 'Content-type: text/html; charset=gb2312' . "rn";
$headers .= 'From: ' . $from . "rn";
mail($to, $subject, $message, $headers);
}
?>@s135.com>
|
function send_mail($from, $to, $subject, $message)
{
if ($from == "")
{
$from = 'Memory of the future ';//Sender address
}
$headers = 'MIME-Version: 1.0' . "rn";
$headers .= 'Content-type: text/html; charset=gb2312' . "rn";
$headers .= 'From: ' . $from . "rn";
Mail($to, $subject, $message, $headers);
}
?>@s135.com>
|
Tips
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, and we must configure it first.
Name Default Description Description Can be changed
SMTP "localhost" Windows only: The DNS name or IP address of the SMTP server. PHP_INI_ALL
smtp_port "25" Windows only: SMTP segment port number. Available since PHP 4.3. PHP_INI_ALL
sendmail_from NULL Windows only: Specifies the "from" address to be used in emails sent from PHP. PHP_INI_ALL
sendmail_path NULL Unix system only: specifies the path of the sendmail program (usually /usr/sbin/sendmail or
/usr/lib/sendmail) PHP_INI_SYSTEM
http://www.bkjia.com/PHPjc/445294.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445294.htmlTechArticle comes with the mailbox sending function mail() in php. We can use this function directly to send emails. Below I Let’s introduce some commonly used mailbox sending examples. The simplest one is the mail function. ...