Smtp
Since PHP does not provide an out-of-the-box SMTP function, it provides a less flexible mail () function that requires support on the server configuration and does not support SMTP authentication and does not work properly in many situations and is therefore not recommended. The purpose of this article is to identify the direction of the novice, and does not involve those advanced content, the level of its own limited, but also worried that can not accurately tell the relevant concepts, and therefore misleading to you, also please learn in-depth.
"Using PHP to send mail" has recently become the second "register_globals" after the new version of the trap, today specifically to write this article for novice doubts, hope can for confused people to indicate the direction.
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 .
Teste
.
Ok:queued as 7b41f4665a
QUIT
221 Bye
Connection closed by foreign host.
Note: The above postfix documents from Netkiller, lazy, directly with ready-made.
The first is to use Telnet to connect to the local 25 port, and a bit of familiarity with the DOT network knows that the SMTP protocol uses 25 ports, which means that the SMTP server is now connected to the local.
Reference:
Trying 127.0.0.1 ...
Connected to localhost.
Escape character is ' ^] '.
server.domain.com.br ESMTP Postfix (2.1.0)
These are the system output information that indicates that it is connected, and that the SMTP server is postfix.
"MAIL from:teste@dominio.com.br" This command indicates that the sender address is teste@dominio.com.br, "OK" indicates that the command is accepted by the server and executed correctly, similar to the HTTP protocol of 200, 404, Status code of 500. The next "RCPT to:teste@dominio.com.br" indicates that the pickup address is teste@dominio.com.br.
Reference:
DATA
354 END Data with .
Teste
.
This paragraph is to enter the message body, enter "DATA" after the system prompts to use " <回车> . <回车> "To end the input, the body content is" teste ".
Finally, quit with "quit".