Using the Mail function in PHP to send an HTML mail instance _php tutorial

Source: Internet
Author: User
Tags configuration settings
In PHP with the mailbox Send function mail () we can directly use this function to send mail, let me introduce some of the commonly used mailbox send instance, the simplest is the mail function.

Cases

The code is as follows Copy Code

function Send_mail ($from, $to, $subject, $message)
{
if ($from = = "")
{
$from = ' Remembering 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);
}
?>

Tips

The program to be used is defined by the configuration settings in the php.ini file, and the behavior of the mail function is affected by the php.ini, which we must first configure.

Name default description can be changed

SMTP "localhost" Windows-specific: The DNS name or IP address of the SMTP server. Php_ini_all
Smtp_port Windows Exclusive: SMTP segment number. Available from PHP 4.3. Php_ini_all
Sendmail_from NULL for Windows Exclusive: Specifies the "from" address to be used in messages sent from PHP. Php_ini_all
Sendmail_path NULL Unix System-specific: Specifies the path to the SendMail program (usually/usr/sbin/sendmail or

/usr/lib/sendmail) Php_ini_system


http://www.bkjia.com/PHPjc/445294.html www.bkjia.com true http://www.bkjia.com/PHPjc/445294.html techarticle in PHP with the mailbox Send function mail () we can directly use this function to send mail, let me introduce some of the commonly used mailbox send instance, the simplest is the mail function. ...

  • 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.