Php sends an email (Method 1)

Source: Internet
Author: User
[Html] 1. & lt; spanstyle & quot; font-size: 18px; & quot; & gt; instance: & lt;/span & gt; [html] 1. $ content & quot; ceshi & quot; 2. $ technicalemail & quot; www.2cto.com & quot; 3. $ headers

[Html]
1. instance:
[Html]
1. $ content = "ceshi ";
2. $ technicalemail = "www.2cto.com ";
3. $ headers = "From: =? UTF-8? B? ". Base64_encode ('chenglong ')."? = <$ Technicalemail> \ r \ n ";
4.
5. $ content = strip_tags ($ content );
6. $ a = @ mail ($ technicalemail, '=? UTF-8? B? '. Base64_encode ('error committing ').'? = ', $ Content, $ headers );
7. if ($)
8 .{
9. echo: The email is sent successfully! ';
10 .}
Send via mail () function:
1. you need to configure the php. ini email information.
Open the php. ini configuration file and configure the red location.
; For Win32 only.
SMTP = localhost --- if sendmail is installed on the local machine, this indicates using the local email server, IP address, and server domain name.
Smtp_port = 25 --- port number
; For Win32 only.
; Sendmail_from = www.2cto.com --- write or not. remove the semicolon here.
; For Unix only. You may supply arguments as well (default: "sendmail-t-I ").
; Sendmail_path = ---- mail server path
2. mail () function
The mail () function allows direct email sending from scripts.
The mail () function returns a boolean value. if the return value is successful, the return value is true. if the return value is failed, the return value is flase.

Mail (to, subject, message, headers, paeameters );

To -- required, specifying the recipient of the email
Subject -- required, specifies the subject of the email. this parameter cannot contain any line feed characters
Message -- required, specifying the message to be sent
Headers -- Optional. specify additional headers, such as from, Cc, and Bcc. For more information, see
Parameters -- Optional, specifying additional parameters of the sendmail program
3. in php. ini, remove ";" Before extension = php_imap.dll.

Author: Vericlongmore

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.