Example of sending HTML email using mail function in php_PHP tutorial

WBOY
Release: 2016-07-20 11:03:31
Original
912 people have browsed it

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.com
truehttp: //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. ...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!