PHP app Tip: send email via SMTP _php

Source: Internet
Author: User
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".

  • 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.