Install and configure sendmail in linux to send emails

Source: Internet
Author: User

Sendmail is an automatic mailbox sending function in linux, but this function is not available by default. We must enable sendmail, next let's take a look at how to send mail by installing and configuring sendmail in linux.

Sendmail configuration

Yum-y update sendmail-cf

SendMail related directories
1. Set the file directory:/etc/mail
2. Record:/var/log/maillog
3. Saved directory of received emails:/var/spool/mail/
4. Temporary directory for sending emails:/var/spool/mqueue/

Back up and modify

Cd/etc/mail
Mv sendmail. cf sendmail. cf. bak

Removes the setting that only the Server can deliver letters.

Vi/etc/mail/sendmail. mc

Change DAEMON_OPTIONS ('port = smtp, Addr = 127.0.0.1, Name = MTA ')
Dnl DAEMON_OPTIONS ('port = smtp, Addr = 127.0.0.1, Name = MTA ')

Add ad source filtering mechanism

In the following two lines
FEATURE ('blacklist _ recipients ') dnl
.
.
EXPOSED_USER ('root') dnl
Join

Dnl # use DNSBL for spam mail
FEATURE ('dnsbl', 'rbl .maps.vix.com ', 'rejected-see http://www.mail-abuse.org/rbl/') dnl
FEATURE ('dnsbl', 'dul .maps.vix.com ', 'dialup-see http://www.mail-abuse.org/dul/') dnl
FEATURE ('dnsbl', 'relays .mail-abuse.org ', 'open spam relay-see http://www.mail-abuse.org/rss') dnl
Dnl FEATURE ('dnsbl', 'relays .ordb.org ',' "Email blocked using ORDB.org-see http://ordb.org" ') dnl
FEATURE ('dnsbl', 'blackholes .mail-abuse.org ',' "Spam blocked see: http://mail-abuse.org/cgi-bin/lookup? "$ & {Client_addr} ') dnl
FEATURE ('dnsbl', 'bl .spamcop.net ',' "Spam blocked see: http://spamcop.net/bl.shtml? "$ & {Client_addr} ') dnl
Dnl FEATURE ('dnsbl', 'dnsbl .sorbs.net', '"554 Rejected" $ & {client_addr} "found in dnsbl.sorbs.net"') dnl
Dnl FEATURE ('dnsbl', 'rbl .softworking.com ',' "550 Mail from" $ & {client_addr} "rejected based on external blacklist-See also http://www.bKjia. c0m/" ') dnl

Configure ad prevention

Yum install milter-greylist

Vi/etc/mail/sendmail. mc, which is added after FEATURE ('dnsbl'... description

Dnl # use GREYLIST for spam mail
FEATURE ('milter-greylist') dnl

Avoid sending emails to machines within the relay range more than twice each time.

Vi/etc/mail/greylist. conf

# Your own network, which shoshould not suffer greylisting

List "my network" addr {127.0.0.1/8 163.32.244.0/24}

# This is a list of broken MTAs that break with greylisting. Derived from # http://cvs.puremagic.com/viewcvs/greylisting/schema/whitelist_ip.txt? Rev = 1.16

List "broken mta" addr {

12.5.136.141/32 # Southwest Airlines (unique sender)

12.5.136.142/32 # Southwest Airlines

163.32.250.21/32 # KH mail server
163.32.250.51/32 # Epass server
163.32.250.12/32 # kiecc. server
# You can also list the mail server IP addresses that are secure (and are sure not to send advertising emails ).

Chkconfig -- level 345 milter-greylist on
Service milter-greylist start

After modifying the sendmail. mc file, the correct sendmail. cf file is generated.

Cd/etc/mail
Make-C/etc/mail

To avoid MX loop back problems, you must log in to the host alias and all host aliases of this Server.

Vi/etc/mail/local-host-names

Set the RELAY scope and DENY the advertisement email host)

Vi/etc/mail/access

Connect: localhost. localdomain RELAY
Connect: localhost RELAY
Connect: 127.0.0.1 RELAY
Connect: 163.18.225 RELAY
Connect: sgrsms.sg-rs.com.hk REJECT
Connect: mail.uhome.net.tw REJECT

After Archiving

Make all
Service sendmail restart
 
Procmail advertising Email Filtering Rules
Yum install procmail

Vi/etc/procmailrc

MAILDIR =/var/mail
VERBOSE = off
PATH =/bin:/sbin:/usr/bin:/usr/sbin/:/usr/local/bin:/usr/local/sbin
LOGFILE =/var/log/procmail. log
# Advertising letter filtering mechanism
# In principle, the probability of misjudgment is high because some electronic journals use relevant programs to send emails. Therefore, these micro-mails are specially transferred to specific files, for manual confirmation in the future. After confirmation, change the settings to/dev/null to delete the letters directly, so as to avoid a waste of hard disk space.
# Filter disguised senders
: 0 HBw
# * ^ Return-Path:. * @ mail.kh.edu.tw .*
* ^ Received: from mail.kh.edu.tw .*
*! ^ Received: from mail.kh.edu.tw. * 163.32.250.
*! ^ Received: from mail.kh.edu.tw. * 163.32.119.
*! ^ Received: from mail.kh.edu.tw. * 163.29.241.
*! ^ Received: from mail.kh.edu.tw. * 163.29.242.
*! ^ Received: from mail.kh.edu.tw. * 163.32.133.
*! ^ Received: from mail.kh.edu.tw (localhost. localdomain [127.0.0.1])
*! ^ Received: from 163.32.250.21.*163.32.250.
/Home/mailfilter/spam. local
# Filter advertising mail sending software (1)
: 0 HBw
* ^ X-Library: (Indy. * | Dynamailer .*)
/Home/mailfilter/spam. library
# Filter advertising mail sending software (2)
: 0 HBw
* ^ X-Mailer: (Dynamailer. * | EhooPost. * | Mail Bomber. * | QuickSender. * | made from pascual | RET. * | FoxMail *)
/Home/mailfilter/spam. mailer

Create a directory for collecting notification Filtering:
Mkdir/home/mailfilter

After setting, compile it in the directory

Cd/etc/mail
Make all
Service sendmail restar
 
Dovecot (POP, IMAP)
 
Install the software bKjia. c0m

Yum-y install dovecot
Cp/etc/dovecot. conf/etc/dovecot. conf. bak
Vi/etc/dovecot. conf

Modify protocols = imap imaps to --> protocols = pop3
Modify ssl_disable = no to --> ssl_disable = yes

Restart

/Etc/rc. d/init. d/dovecot start
Chkconfig dovecot on
 


Sendmail cannot send emails normally

The email content is as follows:

From: =? UTF-8? B? 5b2x6KeG5L + x5LmQ6YOo? = <Webmaster@m.wokan.cc>
X-Priority: 3
X-Mailer: UCENTER_HOME 2.0
MIME-type: 1.0
Content-type: text/html; charset = UTF-8
Content-Transfer-Encoding: base64
Message-Id: <20100513073621.1981D20E333@linux-qebs.site>
Date: Thu, 13 May 2010 15:36:20 + 0800 (CST)
Bytes
Bytes
Bytes
Bytes
Bytes
B2xkO3BhZGRpbmc6NHB4Ij4mbmJzcDsg5b2x6KeG5L + x5LmQ6YOoPC90aD48L3RyPg0KPHRyPjx0
Bytes
IGJnY29sb3I9IiNGRkZGRkYiIGNlbGxwYWRkaW5nPSIyMCI + DQo8dHI + PHRkIHN0eWxlPSJmb250
Bytes
Bytes
CHg7Ij4NCuS6sueIseeahOaci + WPi ++ 8mg0KPGJsb2NrcXVvdGU + PGJyPjxzdHJvbmc + 5Y + W5Zue
5a + G56CB6YKu5Lu2PC9zdHJvbmc + PGJyPuaCqOWPqumcgOWcqOaPkOS6pOivt + axguWQjueahOS4
IeWkqeS5i + WGhe + 8 jOmAmui/h + eCueWHu + S4i + mdoueahOmTvuaOpemHjee9ruaCqOeahOWvhueg
Ge + ge
Bytes
MK/pk77mjqXlvaLlvI/vvizor7flsiblnldlnydmiyvlt6xnspjotlildmty/op4jlmajlnLDl
NYDmoI/lho3orr/pl64pPGJyIC8 + 5LiK6Z2i55qE6aG16Z2i5omT5byA5ZCO77yM6L6T5YWl5paw
55qE5a + G56CB5ZCO5o + Q5Lqk77yM5LmL5ZCO5oKo5Y2z5Y + v5L2/55So5paw55qE5a + G56CB55m7
5b2V5LqG44CCPGJyPjxicj48L2Jsb2NrcXVvdGU + DQo8YnI + DQo8YnI + 5b2x6ke5l + x5LmQ6YOo
Expires + aHR0
CDovL3Yud29rYW4uY2MvaG9tZS88L2E + DQo8YnI + MjAxMC0wNS0xMyAxNTozNjxicj4NCjxicj7m
RaTpgq7ku7bkuLrns7vnu5/oh6rliqjlj5hl1_rnmotpgq7ku7bvvizor7fli7/nm7TmjqXlm57l
Pi3jgiinc1_vdgq + pc90cj48l3rhymxlpg0kpc90zd48l3ryp1_vdgfigu + dqo8l3rkp1_vdhi +
DQo8L3RhYmxlPg =

Obviously not. There must be a problem.

Finding the cause

Not found, not familiar with its configuration, not found on the Internet

Run yast to delete it and reinstall it.

Linux-qebs:/srv/www/htdocs # rpm-qa | grep sendmail
Sendmail-8.14.3-51.5.1.i586

Sendmail-bd-q12h

Vi/etc/sendmail. cf

Modify configurations

Originally

Timeout. ident = 5S

After modification

Timeout. ident = 0 s

/Etc/init. d/sendmail status

No automatic start

/Etc/init. d/sendmail restart

Sendmail 'aaa' xhq6632@126.com

Oh, yes, and it's normal.

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.