Use the mail function in php to send HTML mail instances

Source: Internet
Author: User

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


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.