Linux SendMail mail system installation operation record

Source: Internet
Author: User
Tags auth imap qmail

The composition of the e-mail system:

1) Mail user agent (Mail user agent , mua), MUA is a mail system client program that provides a user interface for reading, sending, and receiving e-mails.   Most commonly used  MUA  has: linux   mail , elm , pine  and so on.  Windows   outlook , foxmail  et  2) mail agent ( mail transfer agent  , MTA )  MTA  responsible for the storage and forwarding of messages ( store and forward ).  MTA  Monitor the user agent's request, locate the corresponding mail server based on the destination address of the e-mail message, transfer the letters between the servers and buffer the received messages.    MTA  programs under  linux  have: sendmail , qmail ,  3) Mail Submission agent ( mail  Submmission Agent , MSA )  MSA  responsible for all the preparation and error detection that must be done before the message has  MTA  send  MSA  is like inserting a sober-minded inspector between  MUA  and  MTA  to detect all of the host names and the information first-class information that is obtained from  MUA .  4) Mail delivery Agent ( Mail Ddlivery Agent , MDA )  MDA  from  MTA  Receive the message and make the appropriate local delivery, you can post a local user, a mailing list, a file or a program.  Linux  Common  MDA  is  MAIL.LOCAL , SMRSH&NBSP, and  procmail  ( www.procmail.org )  5) Mail access agent ( MAIL ACCESS AGENT   MAA )  MAA  is used to connect users to the System mail library, using  POP  or  IMAP  protocols to receive messages.  Linux  Common  MAA  has  UW-IMAP , Cyrus-IMAP , COURIER-IMAP  and so on   Mail relay:  is when the message is transmitted to the destination address, once the source and destination addresses are not local systems, the local system is the trunk of the message (the broker). mua  the user communicates with the mail server through this program, including receiving ( POP3  connecting the recipient Server program  IMAPD) or sending a letter (smtp  connection  mta), for example:  Outlook express ... such as mta  use the  SMTP  protocol to pass letters to different mail hosts, for example:  sendmail, postfix, qmail ... such as msa  is the  client  end agent for the new  sendmail  development to  SSMTP   TLS/SSL  online. mda  the letter is sent to different user mailboxes, is a  MTA  subsystem, such as  BBS  is defined as  MDA ( BBS  function Complex, Of course not only  mda), some  MDA  are designed to do filter action, they have to operate at the  local  end, and therefore called  lda, for example:  procmail ... such as mailbox  e-mail that has not yet been downloaded by the user, will temporarily exist in the server's hard disk space, called the mailbox. All user mailboxes must be approximately equal to half the total capacity of the partition to avoid space in the mailbox but the messaging system is not workingThe phenomenon. mail gateway  is a special kind of mail server, which usually plays the role of agent, which is responsible for coordinating the sending and receiving of all correspondence in an organization, and distributing the mail to the subordinate's mail server, which can speed up the exchange of mails and can carry out consistent filter control. SendMail is a Linux system in a mailbox system, if we configured in the system SendMail can be used directly to send mailboxes.


Configuration file for SendMail

/etc/mail/sendmail.cf:sendmail master configuration file;/etc/mail/access: Relay access control;/etc/mail/domaintable; domain name Mapping;/etc/mail/ Local-host-names;/etc/mail/mailertable: Specifies a special routing rule for a specific domain;/etc/mail/virtusertable: virtual domain configuration.


Configuration of Trunks

means that a server accepts and passes messages that are not the source and destination addresses of the server. Set in two files:/etc/mail/relay-domains/etc/mail/access.


First, install the software

[email protected] ~]# yum install-y sendmail[[email protected] ~]# yum install-y sendmail-cf

Start the SASLAUTHD service for SMTP authentication (installed by default, if not, install manually)

[[Email protected] ~]# service SASLAUTHD startstarting SASLAUTHD: [OK]


Second, the Mail service configuration

1) Configure Senmail SMTP Authentication to remove the DNL in front of the following two lines of content. In the SendMail file, DNL indicates that the behavior comment line is invalid, so you can open the corresponding setting line by removing the DNL string at the beginning of the row. [[EMAIL PROTECTED] ~]# VIM /ETC/MAIL/SENDMAIL.MC ...] Trust_auth_mech (' External digest-md5 cram-md5 login plain ') dnldefine (' ConfAUTH_MECHANISMS ') ,  ' External gssapi digest-md5 cram-md5 login plain ') dnl2)   Set the network access permissions for the SendMail service (if it is a direct native call, you can use the default 127.0.0.1 instead of the operation.) But eventually it changed to 0.0.0.0. Change 127.0.0.1 to 0.0.0.0, meaning that any host can access the SendMail service. If only one segment is allowed to access the SendMail service, change 127.0.0.1 to a specific segment address that is shaped like 192.168.1.0/24. [[EMAIL PROTECTED] ~]# VIM /ETC/MAIL/SENDMAIL.MC ...] Daemon_options (' Port=smtp,addr=0.0.0.0, name=mta ') dnl3) generate configuration file SendMail configuration file is generated by M4, M4 tool in SENDMAIL-CF package. If the system does not recognize the M4 command, it indicates that the SENDMAIL-CF package is not installed [[email protected] ~]# m4 /etc/mail/sendmail.mc >  /ETC/MAIL/SENDMAIL.CF4) Start Service [[email protected] ~]# service sendmail  Startstarting sendmail: [ ok ]starting sm-clienT: [ ok ][[email protected] ~]# service saslauthd restartstopping  saslauthd: [ ok ]starting saslauthd: [ ok ] Join the service in the self-starter row [[email  protected] ~]# chkconfig sendmail on[[email protected] ~]# chkconfig  Saslauthd on[[email protected] ~]# chkconfig --list |grep sendmailsendmail  0:off 1:off 2:on 3:on 4:on 5:on 6:off[[email protected] ~]#  chkconfig --list |grep saslauthdsaslauthd 0:off 1:off 2:on 3:on  4:on 5:on 6:off


Third, test send mailbox

(1) The first way: the installation of SendMail can be used. [[email protected] ~]# yum-y install MAILX Create a message content file, and then send the message (note that the-s parameter after the message header to use single quotation marks, cannot use double quotation marks, otherwise the email will fail!)  ) [[email protected] ~]# echo ' This was test mail ' >/root/content.txt [[email protected] ~]# Cat/root/content.txt this is Test Mail[[email protected] ~]# mail-s ' Test Mail ' ******@163.com </root/content.txt view Received message:


If you do not want to send a message through a file, you can send it, or you can use the pipe character to send the message directly, the effect is the same as the file sent the message content.

[Email protected] ~]# echo "This is Test mail." | Mail-s ' Mail Test ' ******@163.com

View received messages:


If you are sending to multiple messages, use the-c parameter, as follows:

[Email protected] ~]# echo "This is Test mail" | Mail-s ' test '-c ****** @sina. com ******@163.com
(2) The second way: the use of external smpt server in the first way, the/bin/mail command will default to use local sendmail send mail, which requires the local machine must install and start the SendMail service, configuration is very cumbersome, and will bring unnecessary resource consumption. By modifying the configuration file, you can use an external SMTP server to send mail with an external SMTP server without using SendMail. Modify the/etc/mail.rc file (some version is called/etc/nail.rc, add the following content:set [email protected] smtp=smtp.domain.comset  Smtp-auth-user=username smtp-auth-password=passwordset smtp-auth= Login parameter Description: The From is the address of the outgoing SMTP server to which the mail address SMTP is occurring smtp-auth-user is the external SMTP server authenticated user name. Note Be sure to fill in the full name of the message!! Smtp-auth-password is the external SMTP server authentication user password Smtp-auth is the way the message authentication is configured, you can send the message normally, as follows [[email protected] ~]#  vim /etc/mail.rc                      //add set from=******@3dmedcare.com smtp= at the bottom of the file Smtp.3dmedcare.com smtp-auth-user=******@3dmedcare.com smtp-auth-password=3dmed123 smtp-auth= Login now starts sending mail:[[email protected] ~]# echo  "Hello world"  |mail -s  " test666 '  ****[email protected]

Linux SendMail mail system installation operation record

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.