Mail-SMTP protocol for Linux Services

Source: Internet
Author: User
Tags base64 mx record sender policy framework

Yum Install NC NC to replace Telnet

Here we want to let you know one of the experiences in the network protocol: The more parameters, the faster the death, the less the parameter, the longer it lasts. Too many parameters, it is not conducive to use, can not be promoted, sooner or later will be replaced by other agreements. This also conforms to the basic principles of science, simple.

SMTP protocol
SMTP is also a request/response protocol, and commands and responses are based on Ascⅱ text and end with the CR and LF characters. The response includes a three-bit numeric code that represents the return status. SMTP listens for continuous requests on TCP protocol Port 25th.
Since this protocol is initially based on pure Ascⅱ text, it is not well handled on binary files. The standard used to encode binary files, such as MIME, was later developed so that it could be transmitted through SMTP. Today, most SMTP servers support 8-bit MIME extensions, which make the transfer of binary files almost as simple as plain text.
Junk e-mail is still an important issue. One of the limitations of the original SMTP protocol is that it does not have the ability to authenticate the sender. The Smtp-auth extension is therefore defined. Because of the network effect of SMTP's huge installation base, it is considered unrealistic to modify SMTP extensively or replace it completely. Internet Mail 2000 is one such recommendation for substitution. IRTF's anti-spam research team is working on a number of recommendations that provide simple, flexible, lightweight, and upgradeable source-side authentication. The most likely accepted recommendation is the sender Policy Framework protocol.

Message routing process for SMTP protocol
The SMTP server routes e-mail messages based on the Domain Name Service DNS in which the intended recipient is routed. The SMTP server routes e-mail based on MX records in DNS, the MX record registers the domain name and the associated SMTP relay host, and the e-mail that belongs to that domain should be sent to that host. If the SMTP server mail.abc.com received a letter to [email protected], perform the following procedure:
(1) Sendmail request DNS to give the CNAME record of the host sh.abc.com, if so, if the CNAME (alias record) to shmail.abc.com, then request Shmail.abc.com's CNAME record again until there is no.
(2) Assuming that the CNAME is to shmail.abc.com, then sendmail requests the DNS of the @abc.com domain to give shmail.abc.com MX records (mail Routing and Logging), Shmail MX 5 SHMAIL.ABC.COM10 Shmail2.abc.com.
(3) SendMail combination request DNS gives shmail.abc.com a record (hostname (or domain name) corresponding to the IP address record), that is, the IP address, if the return value is 1.2.3.4 (assumed value).
(4) SendMail and 1.2.3.4 connection, send this to [e-mail protected] letter to 1.2.3.4 This server's SMTP daemon.

The SMTP command is the Ascⅱ information that is sent between the SMTP hosts, and the command that may be used is shown in the following table.

SMTP protocol commands
Command Describe
DATA Start information Writing
Expn<string> Verifies that a given list of mailboxes exists, expands the list of mailboxes, and is often disabled
Helo<domain> Identify the user to the server and return to the mail server identity
Help<command> What commands are supported by the query server and return information from the command
MAIL from Initializing a mail session on the host
NOOP No action, the server should respond OK
QUIT Terminating a mail session
RCPT to<user> Identifies a single recipient of a message; You can often have multiple rcpt to after the Mail command:
RSET Reset session, the current transfer is canceled
SAML from Send mail to user terminal and mailbox
SEND from Send mail to User terminal
SOML from Send a message to a user terminal or mailbox
TURN Receive-side and send-side exchange roles
Vrfy<user> Used to verify that the specified user/mailbox exists and that the server often prohibits this command for security reasons

EHLO is an extension to helo, that is, extend helo, which can support authentication, that is, user authentication.

Helo is a normal SMTP, without authentication can continue to mail from down until the successful delivery of the message, that is, you can forge the mail!
EHLO is ESMTP with authentication, so it can't be forged.

It is also possible to send from remote to another remote.

[[Email protected] log]# NC mail.sohu.com 25
Zw_71_21 ESMTP Ready
EHLO mail.sohu.com indicates that he needs authentication
250-zw_71_21
250-auth PLAIN LOGIN
STARTTLS
Auth Login indicates authentication started
334 VXNLCM5HBWU6 Base64 encoded username:
y3jlyxrlexvhbg== user name encoded by base64
334 UGFZC3DVCMQ6 Base64 Encoded password:
MMQ0NTY3ODKT Password encoded by base64
235 2.0.0 OK
Mail From:[email protected] declares the sender of the message
2.1.0 Ok
RCPT To:[email protected] declaring message recipients
2.1.5 Ok
Data Mail Start
354 end data with <CR><LF>.<CR><LF> below is the message header ID, which is not related to post, and the server indicates that the message that ends in SMTP is to include both the envelope and the content.
Subject:test MAILFJ Themes
From:[email protected] Declares the source of the message in the message header and is only displayed in Outlook and Foxmail, regardless of the post
To:[email protected] These two from and to does not matter, can write casually

Wo shi he da empty line, identifying message header and content
Sfj
Please delete it.
. End With Point
2.0.0 ok:queued as 256062628456
Quit
221 2.0.0 Bye
[Email protected] log]#

It is possible to send a message locally to a specified mailbox

[[Email protected] log]# NC localhost 25
109-com1.localdomain ESMTP Postfix
Helo localhost
109-com1.localdomain
EHLO localhost
250-109-com1.localdomain
250-pipelining
250-size 10240000
250-vrfy
250-etrn
250-enhancedstatuscodes
250-8bitmime
DSN
Mail From:[email protected]
2.1.0 Ok
RCPT To:[email protected]
2.1.5 Ok
Data
354 END data with <CR><LF>.<CR><LF>
Wwwwwwww
Wweeeeeeeee
Rrrrrrrrrrr
.
2.0.0 ok:queued as 14c5a80612
Quit
221 2.0.0 Bye
[Email protected] log]#

Linux Email

Self-Service mail server trouble is also easy to intercept, you can use the Linux next mail command to connect to the third-party mail server's SMTP server to send mail. Write the sender's address to/etc/mail.rc before you can send mail with mail.
#/bin/bash
[Email protected] Sender address
Smtpserver=smtp.126.com
User=createyuan1
passwd=*******
Cat <<eof >/etc/mail.rc
Set from= $mailaddr
Set smtp= $smtpserver
Set Smtp-auth=login
Set smtp-auth-user= $user
Set smtp-auth-password= $passwd
Eof

Send mail: 3 ways
Mail-v-S "Subject" [email protected] #Enter键后输入正文 recipient address
Mail-v-S "Theme" [email protected] < file #file内容为正文
echo "Body" |mail-v-S "Theme" [email protected] #以重定向输入为正文

Mail-SMTP protocol for Linux Services

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.