By default, when the sendmail starts, it sends email directly.

Start sendmail

/sbin/service sendmail start

It is because /etc/mail/sendmail.mc has commented out the SMART_HOST.

dnl define(`SMART_HOST',`shawmail.vc.shawcable.net')dnl

Because we bought a static IP address from SHAW, the port:25 is open. The following email is successfully delivered.

echo "test mail" | /usr/sbin/sendmail kaiming.liao@gmail.com


net1

How do I receive email from other email system?

vi /etc/mail/sendmail.mc

dnl LOCAL_DOMAIN(`localhost.localdomain')dnl

LOCAL_DOMAIN(`1ask2.com')
LOCAL_DOMAIN(`kaiming.com')

dnl DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1,Name=MTA')dnl

DAEMON_OPTIONS(`Port=smtp,Name=MTA')dnl

vi /etc/mail/virtusertable

root root@1ask2.com root@kaiming.com

/sbin/service sendmail restart

Configuring DNS

Assuming the IP address of linux is 191.121.4.81

1ask2.com zone

Create host records:

1ask2.com 191.121.4.81
mail.1ask2.com 191.121.4.81

Create MX record:

MX mail.1ask2.com

kaiming.com zone

Create host records:

kaiming.com 191.121.4.81
mail.kaiming.com 191.121.4.81

Create MX record:

MX mail.kaiming.com

kaiming@vanarts.com successfully sends email to both root@1ask2.com and root@kaiming.com.


smart host configuration

network relay

Exchange server: Receive Connector:relay for IP address 191.121.4.81 with basic authentication.

1.

vi /etc/mail/sendmail.mc

define(`SMART_HOST',`mail.vanarts.com')


dnl define(`SMART_HOST', `smtp.your.provider')dnl
define(`SMART_HOST',`mail.vanarts.com')dnl
define(`RELAY_MAILER_ARGS',`TCP $h 25')dnl
define(`ESMTP_MAILER_ARGS',`TCP $h 25')dnl

FEATURE(`authinfo',`hash /etc/mail/auth/client-info')dnl
TRUST _AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl

2.

mkdir /etc/mail/auth
vi /etc/mail/auth/client-info
AuthInfo:mail.vanarts.com "U:root" "I:relayUser@vanarts.com" "P:relayPass"

3.

cd /etc/mail/auth
makemap hash client-info < client-info
chmod 700 /etc/mail/auth
chmod 600 /etc/mail/auth/*

4.

/etc/init.d/sendmail restart

5.

test email delivery:

echo "test relay" | /usr/sbin/sendmail kaiming.liao@gmail.com


Using smtp.gmail.com for relaying

1.

vi /etc/mail/sendmail.mc

dnl define(`SMART_HOST', `smtp.your.provider')dnl
define(`SMART_HOST',`smtp.gmail.com')dnl
define(`RELAY_MAILER_ARGS',`TCP $h 587')dnl
define(`ESMTP_MAILER_ARGS',`TCP $h 587')dnl

FEATURE(`authinfo',`hash /etc/mail/auth/client-info')dnl
TRUST _AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl


2.

mkdir /etc/mail/auth
vi /etc/mail/auth/client-info
AuthInfo:mail.vanarts.com "U:root" "I:kaiming.liao@gmail.com" "P:relayPass"

3.

cd /etc/mail/auth
makemap hash client-info < client-info
chmod 700 /etc/mail/auth
chmod 600 /etc/mail/auth/*

4.

/etc/init.d/sendmail restart


Install dovecot (IMAP and POP3)

yum install dovecot

vi /etc/dovecot/dovecot.conf

disable_plaintext_auth=no
protocols = imap pop3
mail_location=mbox:~/mail:INBOX=/var/spool/mail/%u


Locally installed email clients, such as Thunderbird, can send and receive email. However, email clients installed on other computers cannot send email with relaying rejected.

local host relay

Solution:

vi /etc/mail/sendmail.mc

FEATURE(relay_entire_domain)

/etc/init.d/sendmail restart

Problem: everyone can send email through sendmail without authentication.

Because the hostname is 1ask2.com, any host in any of the local domains (that is, class{m}) will be relayed. The thunderbird in Windows computer can send email through Linux sendmail.

However, if the linux hostname is set to linux.1ask2.com and run /etc/init.d/sendmail restart, the thunderbird in Windows computer cannot send out email through Linux sendmail.




The following configuration only allows 191.121.6.2 computer to relay.

vi /etc/mail/sendmail.mc

dnl FEATURE(relay_entire_domain)dnl

FEATURE(`access_db', `hash -T<TMPF> -o /etc/mail/access.db')dnl

vi /etc/mail/access

Connect:localhost.localdomain           RELAY
Connect:localhost                       RELAY
Connect:127.0.0.1                       RELAY
191.121.6.2                            RELAY

makemap hash /etc/mail/access.db < /etc/mail/access

The Windows computer can send email out through Linux sendmail.

Because my Windows workstation is a member of vanarts.com domain, to relay email without setting FEATURE(relay_entire_domain), I could add a line to /etc/mail/access

vi /etc/mail/access

Connect:localhost.localdomain           RELAY
Connect:localhost                       RELAY
Connect:127.0.0.1                       RELAY
vanarts.com                           RELAY

 

makemap hash /etc/mail/access.db < /etc/mail/access


The default configuration for sendmail (smtp) does not need authentication.

When the following configurations are added to /etc/mai/sendmail, the sendmail can send email out without authentication and with authentication (PLAIN_TEXT)

define(`confAUTH_OPTIONS', `A p')dnl
define(`confAUTH_MECHANISMS', `LOGIN PLAIN')dnl
TRUST_AUTH_MECH(`LOGIN PLAIN')dnl