PHP uses SMTP class to implement e-mail sending code example

Source: Internet
Author: User
The SMTP (Simple Mail Transfer Protocol) is simply the message Transfer Protocol, which is a set of rules for sending mail from the source address to the destination, and it controls the way the letters are relayed. The SMTP protocol is a TCP/IP protocol cluster that helps each computer find its next destination when sending or relaying letters. Through the server specified by the SMTP protocol, e-Mail can be sent to the recipient's server, the whole process only a few minutes. An SMTP server is a sending mail server that follows the SMTP protocol and is used to send or relay e-mail messages.

It uses a reliable data transfer service provided by TCP to transfer mail messages from the sender's mail server to the recipient's mail server. As with most application layer protocols, SMTP also has two ports: clients executed on the sender's mail server and server side executed on the recipient's mail server. The client and server side of SMTP are running on each mail server at the same time. When a mail server sends a mail message to another mail server, it is running as an SMTP client.

There are many similarities between the SMTP protocol and the etiquette that people use to interact with each other. First, the SMTP client running on the sending-side mail server host initiates a TCP connection to the SMTP server port number 25 running on the receiving mail server host. If the receiving mail server is not currently working, the SMTP customer waits for a period of time before attempting to establish the connection. The SMTP client and server perform some application-level handshake operations first. Just as people tend to introduce themselves before they turn things around, SMTP clients and servers also introduce themselves before transmitting information. During this SMTP handshake phase, the SMTP client indicates to the server the e-mail address of the sender and recipient respectively. After we have introduced ourselves, the customer sends out an email message.

This article mainly introduces PHP using SMTP class easy to send e-mail, SMTP class send mail method is actually very simple, the need for friends can refer to the following

Here's the core code:

<?php require_once "email.class.php"; Configuration information ******************************** $smtpserver = "smtp.126.com";//SMTP Server $smtpserverport = 25;//SMTP Server Port $smtpusermail = "new2008oh@126.com"; user mailbox for//smtp server $smtpemailto = $_post[' toemail '];//sent to who $smtpuser = " New2008oh ";//smtp Server user account $smtppass =" Your mailbox password ",//SMTP server user Password $mailtitle = $_post[' title '];//message subject $mailcontent =" < H1> ". $_post[' content ']." 
Related Article

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.