Http: // 10.1.1.35/ule_basic/ule15_sendmail.txt

Source: Internet
Author: User
Tags imap smtp auth dovecot
--

Sendmail

MUa (Mail User Agent), which is used to send or read emails from the client. The tool mutt is available in Linux.

MTA (Mail tranfer agent) is equivalent to a post office and server-side software. It provides the following functions: receiving emails from Mua and sending emails to the next MTA, it can be said that it is a mail router, and the server-side software belongs to MTA. Now open-source products include sendmail, Postfix, Qmail, etc.

MDA (Mail devilery agent mail delivery agent) is mainly used to place the message received by the MTA to the local account or to the next MTA according to the mail destination, generally, it refers to commands such as mail.

Email protocol:

Send mail: SMTP (Simple Mail tranfer protocol Simple Mail Transfer Protocol) port number TCP port 25, when sending a mail, Mua will actively connect to the MTA port 25, and then send out through SMTP protocol, SMTP can be divided into accepting SMTP and sending SMTP, regardless of the configuration of both hosts or the system, as long as both sides of the SMTP protocol OK can send mail

Receive mail: Pop (Post Office Protocol) to connect to the MTA to read or download emails. Currently, the commonly used version is POP3 and the port is 110.
IMAP (Internet Message Access Protocol Network File protocol), you can download the mail header information before downloading the mail, so that users can choose to download port 143

Software Package

Yum install Sendmail *
Yum install Dovecot

Sendmail. i386 -- Message Server MTA
Sendmail-cf.i386-configuration package
Sendmail-devel.i386-Development Kit
Sendmail-doc.i386-document pack
Dovecot. i386 -- (pigeon house), POP Mail Server MDA
M4.i386 -- process the configuration file package

Port: SMTP (25) POP3 (110) IMAP (143)

Protocol: TCP

Service Startup Script:

/Etc/init. d/sendmail
/Etc/init. d/Dovecot

Configuration file:
/Etc/mail/sendmail. cf -- main configuration file read when the Sendmail mail service is started
/Etc/mail/sendmail. MC -- the configuration file used by the Administrator to modify the sendmail server function
/Etc/mail/Local-host-names -- configure to support the use of short domain names when sending emails
/Etc/mail/login usertable -- virtual user list
/Etc/aliases -- User alias
/Etc/mail/access -- Mail Relay

/Etc/init. d/sendmail restart

[Root @ Li ~] # Netstat-NTL | grep 25 -- the default value is 127.0.0.1.
TCP 0 0 127.0.0.1: 25 0.0.0.0: * listen

-- Method 1:
[Root @ Li ~] # Mail-s "mail" root@li.cluster.com -- Use this command to send the mail-s followed by the mail subject
1111 -- Write email content
. -- "." Indicates the end
Cc: -- press enter to exit

[Root @ Li ~] # Mail-s 'yyyy' a@li.cluster.com set type = mx
> Cluster.com
Server: 10.1.1.35
Address: 10.1.1.35 #53

Cluster.com mail exchanger = 0 li.cluster.com. -- if you see this information, it indicates that the operation is successful.

It is best to configure time synchronization.
[Root @ Li mail] # echo 'while:; do ntpdate 10.1.1.1>/dev/null 2> & 1; sleep 10; done '>/etc/rc. Local

-- Synchronize 10.1.1.1 every 10 seconds, put it in/etc/rc. Local, and run automatically upon startup

Copy the email client software claws-mail and install it.
Ls/share/soft/mail_client/

Tar xvf/share/soft/mail_client/claws-mail-3.5.0.tar.gz-C/usr/src/

Tar xvf/share/soft/mail_client/libetpan-0.57.tar.gz-C/usr/src/

CD/usr/src/libetpan-0.57/

./Configure; Make; make install

CD/usr/src/claws-mail-3.5.0/

./Configure; Make; make install

Example 1: Let the SMTP protocol listen to all ports

Vim/etc/mail/sendmail. MC

Daemon_options ('port = SMTP, ADDR = 0.0.0.0, name = MTA ') DNL -- change 127.0.0.1 to 0.0.0.0, or remove the middle section

Save and exit

M4/etc/mail/sendmail. MC>/etc/mail/sendmail. cf -- if the m4.i386 package is not installed, use the M4 command to generate Sendmail. the cf configuration file is not required after it is installed. Restart the sendmail service to automatically generate the file.

/Etc/init. d/sendmail restart

[Root @ Li claws-mail-3.5.0] # netstat-NTL | grep 25
TCP 0 0 0.0.0.0: 25 0.0.0.0: * listen

[Root @ Li claws-mail-3.5.0] # telnet 10.1.1.35 25 -- test the SMTP protocol on the local IP address (non-loopback address). If you only listen to 127.0.0.1, you cannot use an IP address for testing.
Trying 10.1.1.35...
Connected to li.cluster.com (10.1.1.35 ).
Escape Character is '^]'.
220 li.cluster.com ESMTP Sendmail 8.13.8/8.13.8; sat, 29 May 2010 13:47:01 + 0800
Helo li.cluster.com
250 li.cluster.com
.................

Example 2: Use claws-mail to send and receive emails

When claws-mail is used to send an email to a local user, it can be written. However, when receiving the email, it will report a failure to connect to pop.cluster.com: 110.

Cause test:
[Root @ Li/] # NSLookup pop.cluster.com -- View DNS first and parse
Server: 10.1.1.35
Address: 10.1.1.35 #53

Name: pop.cluster.com
Address: 10.1.1.35

Netstat-NTL | grep 110 -- check the port again. If no port 110 is found, it indicates that the POP3 protocol is not configured.

So configure the Dovecot Service
[Root @ Li/] # Vim/etc/Dovecot. conf

Protocols = IMAP IMAPs POP3 pop3s -- locate a comment on the 20 rows, open the comment, or write a line, indicating that POP3 and IMAP protocols are supported.

/Etc/init. d/Dovecot restart -- after the service is restarted, the listening ports 143 and 110 are enabled.

[Root @ Li/] # netstat-ntlup | grep 143
TCP 0 0: 143: * Listen 21674/Dovecot
[Root @ Li/] # netstat-ntlup | grep 110
TCP 0 0: 110: * Listen 21674/Dovecot

Then you can receive the email.

Example 3: Use a short domain name to send emails

[Root @ Li/] # mail-s '000000' a@cluster.com -- use a short domain name
222222
.
Cc:

[Root @ Li/] # tail/var/mail/A -- cannot be viewed, indicating that short domain names are not supported

[Root @ Li/] # tail/var/mail/root -- you can see that the email address is thrown to the root account.

Configuration method:
[Root @ Li/] # Vim/etc/mail/Local-host-names -- write the following two sentences
Host Name of the current server
Local server Domain Name

/Etc/init. d/sendmail reload

Sending and testing with a short domain name can be successful.

Example 4: email alias, Email Forwarding, and mass mailing
[Root @ Li/] # Vim/etc/aliases
Add

A: B -- indicates the email sent to user a and sent to user B. User A cannot receive the email himself.
C: d, e, f -- indicates to send an email from user C to user D, E, and F. User A cannot receive the email by himself.
Salegroup: include:/etc/mail/salegroup -- you can also write this statement to group some users. Note that/etc/mail/salegroup does not exist, to manually create and write the members of this group into, one row of a user; the user name to be given during the test should be written as salegroup, for example: Mail-s '000000' salegroup@cluster.com

/Etc/init. d/sendmail reload

Example 5: email virtual account, virtual user table
[Root @ Li/] # Vim/etc/mail/login usertable

A@cluster.com B @cluster.com -- Virtualize B @cluster.com accounts into a@cluster.com accounts
@ Cluster.com c -- all emails sent to the cluster.com domain will be sent to the local C user's mailbox

/Etc/init. d/sendmail reload

Example 5: email relay

If the above configuration remains unchanged, use another computer for testing.
[Root @ DNS ~] # Telnet 10.1.1.35 25 -- test the SMTP protocol on this server on another computer.
Trying 10.1.1.35...
Connected to 10.1.1.35 (10.1.1.35 ).
Escape Character is '^]'.
220 li.cluster.com ESMTP Sendmail 8.13.8/8.13.8; sat, 29 May 2010 15:39:36 + 0800
Helo dns.lu.com
250 li.cluster.com Hello [10.1.1.218], pleased to meet you
Mail from: sdfsa@baidu.com
250 2.1.0 sdfsa@baidu.com... sender OK
Rcpt to: sfsadfa@qq.com
550 5.7.1 sfsadfa@qq.com... relaying denied. -- you can see the relay rejection

[Root @ Li/] # Vim/etc/mail/access -- only 127.0.0.1 relay is allowed by default

Connect: 10.1.1.218ok -- a very trusted host can use OK
Connect: 10.1.1 relay -- allow 10.1.1.0 network segment Relay
From: Sina. comreject -- indicates that all emails from Sina.com are rejected.
To: Baidu. comdiscard -- discard emails from Baidu.com

-- Difference between reject and discard: discard is discarded directly, and an error or warning is returned for reject.

I added
Connect: 10.1.1 Relay

/Etc/init. d/sendmail reload

Test it with another computer (if 10.1.1.0 is used, because I only allow this network segment relay)

[Root @ DNS ~] # Telnet 10.1.1.35 25
Trying 10.1.1.35...
Connected to 10.1.1.35 (10.1.1.35 ).
Escape Character is '^]'.
220 li.cluster.com ESMTP Sendmail 8.13.8/8.13.8; sat, 29 May 2010 15:51:35 + 0800
Helo DNS. lu. Con
250 li.cluster.com Hello [10.1.1.218], pleased to meet you
Mail from: sfsafa@163.com
250 2.1.0 sfsafa@163.com... sender OK
Rcpt to: sdfsadf@gmail.com
250 2.1.5 sdfsadf@gmail.com... recipient OK -- no relay deny error reported in this test

-------------------------------------------------------------------

Use SMTP for verification

Yum install cyrus-sasl *

Vim/etc/mail/sendmail. MC -- open the following three lines of comment

Trust_auth_mech ('external DIGEST-MD5 CRAM-MD5 login plain ') DNL
Define ('confauth _ mechanisms ', 'external gssapi DIGEST-MD5 CRAM-MD5 login plain') DNL

Daemon_options ('port = Submission, name = MSA, M = EA ') DNL

/Etc/init. d/sendmail restart
/Etc/init. d/Dovecot restart
/Etc/init. d/saslauthd restart

[Root @ Li/] # telnet 10.1.1.35 25
Trying 10.1.1.35...
Connected to li.cluster.com (10.1.1.35 ).
Escape Character is '^]'.
220 li.cluster.com ESMTP Sendmail 8.13.8/8.13.8; sat, 29 May 2010 16:42:54 + 0800
EHLO li.cluster.com -- note that EHLO is not helo.
250-li.cluster.com Hello li.cluster.com [10.1.1.35], pleased to meet you
250-enhancedstatuscodes
250-pipelining
250-8bitmime
December 250-size
250-dsn
250-etrn
250-auth gssapi DIGEST-MD5 CRAM-MD5 login plain -- see here there is login plain verification information indicating support for SMTP Verification
250-deliverby
250 help

Verification:
[Root @ Li/] # telnet 10.1.1.35 25
Trying 10.1.1.35...
Connected to li.cluster.com (10.1.1.35 ).
Escape Character is '^]'.
220 li.cluster.com ESMTP Sendmail 8.13.8/8.13.8; sat, 29 May 2010 16:45:12 + 0800
Helo li.cluster.com
250 li.cluster.com Hello li.cluster.com [10.1.1.35], pleased to meet you
Mail from: fsfafa@baidu.com
250 2.1.0 fsfafa@baidu.com... sender OK -- verification is not required here

Cause: SMTP authentication is only performed on port 587 by default, instead of port 25. Therefore, you can directly Telnet 10.1.1.35 to avoid SMTP authentication.

Vim/etc/mail/sendmail. MC

Take the following sentence
Daemon_options ('port = Submission, name = MSA, M = EA ') DNL
Change
Daemon_options ('port = 25, name = MSA, M = EA ') DNL

And
Daemon_options ('port = SMTP, ADDR = 0.0.0.0, name = MTA ') DNL -- Comment out this name. Note that DNL is used for annotation. No need #

-- Indicates that SMTP authentication is enforced.

/Etc/init. d/sendmail restart

[Root @ Li/] # telnet 10.1.1.35 25
Trying 10.1.1.35...
Connected to li.cluster.com (10.1.1.35 ).
Escape Character is '^]'.
220 li.cluster.com ESMTP Sendmail 8.13.8/8.13.8; sat, 29 May 2010 16:55:58 + 0800
Helo li.cluster.com
250 li.cluster.com Hello li.cluster.com [10.1.1.35], pleased to meet you
Mail from: sfsafsa@sina.com
530 5.7.0 authentication required -- Now you will see the verification required
Auth login -- start Verification
334 vxnlcm5hbwu6
A -- enter the user name. An error is returned because base64-bit encoding is used.
501 5.5.4 cannot decode auth parameter
AUTH LOGIN
334 vxnlcm5hbwu6
Yq = -- this is the base64 encoding of.
334 ugfzc3dvcmq6
Mtiz -- this is the base64 encoding of 123.
235 2.0.0 OK authenticated -- the verification is successful and an email can be sent.
Mail from: sdfasfas@sina.com
250 2.1.0 sdfasfas@sina.com... sender OK
Rcpt to: B @cluster.com
250 2.1.5 B @cluster.com... recipient OK
Data
354 enter mail, end with "." on a line by itself
Last test
.
250 2.0.0 o4t8twfu025598 message accepted for delivery
Quit
221 2.0.0 li.cluster.com closing connection
Connection closed by foreign host.

CAT/var/mail/B indicates the sent email.

---------------

Use claws-mail for verification

Click Settings-Current Account preference settings-send-set SMTP authentication (smtp auth) select plain as the authentication method. Enter a common name of the Local Machine and Its password as the user ID and password.

Re-send emails and so on are all verified by SMTP

-------------------

Below is a base64 code online conversion page

Http://www.motobit.com/util/base64-decoder-encoder.asp

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.