Use the mail function in php to send HTML mail instance _ PHP Tutorial

Source: Internet
Author: User
Use the mail function in php to send HTML mail instances. 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. 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:

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


You can use this function to send emails directly. next I will introduce some common email sending instances. 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.