Send mail via SMTP in PHP

Source: Internet
Author: User
Tags exit mail connect reference domain

because PHP does not provide out-of-the-box SMTP functions, it provides a less flexible mail () function that requires support on the server configuration and does not support SMTP authentication, and is not recommended for use in many situations. The purpose of this article is to specify the direction for the novice, and did not involve those advanced content, a limited level of their own, and also worry about not accurate to tell the relevant concepts, and thus mislead you, but also to learn their own in-depth.

"Use PHP to send mail" has recently become a "register_globals" after the second novice trap, today specially write this article for novice FAQ, hoping to be confused for the direction of the people.

let's start with the following example:

Reference:

[root@server~/]# telnet localhost 25
Trying 127.0.0.1 ...
Connected to localhost.
Escape character is ' ^] '.
server.domain.com.br ESMTP Postfix (2.1.0)
MAIL from:teste@dominio.com.br
Ok
RCPT to:teste@dominio.com.br
Ok
DATA
354 End data with <CR><LF>.<CR><LF>
Teste
.
Ok:queued as 7b41f4665a
QUIT
221 Bye
Connection closed by foreign host.

Note: The above from netkiller postfix documents, lazy, directly with ready-made.

The first is to use Telnet to connect to local port 25, and people who are slightly familiar with the DOT network know that the SMTP protocol uses port 25, which means that it is now connected to the local SMTP server.

Reference:

Trying 127.0.0.1 ...
Connected to localhost.
Escape character is ' ^] '.
server.domain.com.br ESMTP Postfix (2.1.0)

These things are system output information that is already connected, and this SMTP server is postfix.

The "MAIL from:teste@dominio.com.br" command indicates that the address is teste@dominio.com.br, "OK" indicates that the command was accepted and properly executed by the server, similar to the HTTP protocol 200, 404, 500 and so on status code. The next "RCPT to:teste@dominio.com.br" indicates that the recipient address is teste@dominio.com.br.

Reference:

DATA
354 End data with <CR><LF>.<CR><LF>
Teste
.

This paragraph is the input message body, enter "DATA" after the system prompts to use "< return >.< return >" To end the input, the body content is "teste".

Finally, use "QUIT" to exit.

Note: The above from netkiller postfix documents, lazy, directly with ready-made.

The first is to use Telnet to connect to local port 25, and people who are slightly familiar with the DOT network know that the SMTP protocol uses port 25, which means that it is now connected to the local SMTP server.

Reference:

Trying 127.0.0.1 ...
Connected to localhost.
Escape character is ' ^] '.
server.domain.com.br ESMTP Postfix (2.1.0)

These things are system output information that is already connected, and this SMTP server is postfix.

The "MAIL from:teste@dominio.com.br" command indicates that the address is teste@dominio.com.br, "OK" indicates that the command was accepted and properly executed by the server, similar to the HTTP protocol 200, 404, 500 and so on status code. The next "RCPT to:teste@dominio.com.br" indicates that the recipient address is teste@dominio.com.br.

Reference:

DATA
354 End data with <CR><LF>.<CR><LF>
Teste
.

This paragraph is the input message body, enter "DATA" after the system prompts to use "< return >.< return >" To end the input, the body content is "teste".

Finally, use "QUIT" to exit.

Note: The above from netkiller postfix documents, lazy, directly with ready-made.

The first is to use Telnet to connect to local port 25, and people who are slightly familiar with the DOT network know that the SMTP protocol uses port 25, which means that it is now connected to the local SMTP server.

Reference:

Trying 127.0.0.1 ...
Connected to localhost.
Escape character is ' ^] '.
server.domain.com.br ESMTP Postfix (2.1.0)

These things are system output information that is already connected, and this SMTP server is postfix.

The "MAIL from:teste@dominio.com.br" command indicates that the address is teste@dominio.com.br, "OK" indicates that the command was accepted and properly executed by the server, similar to the HTTP protocol 200, 404, 500 and so on status code. The next "RCPT to:teste@dominio.com.br" indicates that the recipient address is teste@dominio.com.br.

Reference:

DATA
354 End data with <CR><LF>.<CR><LF>
Teste
.

This paragraph is the input message body, enter "DATA" after the system prompts to use "< return >.< return >" To end the input, the body content is "teste".

Finally, use "QUIT" to exit.

Total 2 page: previous 1 [2] Next page



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.