Monday, 7 March 2016

Sendmail Installation And Configuration CentOS


Sendmail Installation
=====================

Our main purpose to sending mail only from outlook.


1. Install the system with below details.

    OS = CentOS 6.4
    HOSTNAME = smtp.example.com
    IP ADDR  = 192.168.0.100
    DNS A    = smtp.example.com  A    192.168.0.100
   
    ]# yum update -y
    ]# reboot

2. Install sendmail and m4 packages,

    ]# yum install sendmail* m4* -y

3. Edit configuration file, so the given line looks like below,
   
    add dnl # before below line
    ]# vi /etc/mail/sendmail.mc

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

4. Compile the configuration,

    ]# m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf

5. Start the sendmail service,

    ]# service sendmail start
    ]# chkconfig sendmail on

6. Allow access to IPs to access this SMTP server, Here you generally specify your local internet ip.

    ]# vi /etc/mail/access

    Connect:202.52.134.200            RELAY

    :wq

    ]# service sendmail restart

After successfully installed sendmail then add dns MX and TXT record for your domain.
If TXT record not added then email will land in junk box [spam] to recipient.

You can generate TXT record from here for your domain:-
http://www.microsoft.com/mscorp/safety/content/technologies/senderid/wizard/

Configure Outlook for sending mails.

Steps:-
1. Open Outlook.
2. Select Account Settings from Tools menu
3. Under Emil Tab --> Click New
4. Click Next
5. Select Check Box "Manually configure sever settings or additional server types"
6. Click Next --> Next
7. Enter Your any one existing valid email id and details
Enter Below Server Settings :-

Incoming mail server : enter your incoming mail server setting
Outgoing mail server : Enter Your mail server IP address which one you have configured Sendmail

8. Click Next
9. Close

Note:- do not select outgoing server require authentication from more settings keep as it by default port number settings..!


Now try to send mail from outlook......!
and check mail server logs

[root@server~]# tail -f /var/log/maillog

Output:-
Sep  8 12:32:48 server sendmail[21747]: r888Wjfn021747: from=<mail@namdev.net>, size=381, class=0, nrcpts=1, msgid=<201309080832.r888Wjfn021747@server.sunami.in>, proto=ESMTP, daemon=MTA, relay=[115.240.17.92]
Sep  8 12:32:50 server sendmail[21749]: r888Wjfn021747: to=<mail@namdev.net>, delay=00:00:03, xdelay=00:00:01, mailer=esmtp, pri=120381, relay=cf1ea0177a5f419967...pamx1.hotmail.com. [65.54.188.109], dsn=2.0.0, stat=Sent ( <201309080832.r888Wjfn021747@server.sunami.in> Queued mail for delivery)
Sep  8 12:33:41 server sendmail[21750]: r888XZNJ021750: from=<mail@namdev.net>, size=2403, class=0, nrcpts=1, msgid=<000001ceac6e$1d2e59c0$578b0d40$@net>, proto=ESMTP, daemon=MTA, relay=[115.240.17.92]
Sep  8 12:34:44 server sendmail[21752]: STARTTLS=client, relay=gmail-smtp-in.l.google.com., version=TLSv1/SSLv3, verify=FAIL, cipher=RC4-SHA, bits=128/128
Sep  8 12:34:45 server sendmail[21752]: r888XZNJ021750: to=<namdev.it@gmail.com>, delay=00:01:08, xdelay=00:01:02, mailer=esmtp, pri=122403, relay=gmail-smtp-in.l.google.com. [74.125.129.27], dsn=2.0.0, stat=Sent (OK 1378629285 ct5si6245880pbb.41 - gsmtp)


Enjoy................!


===========================================================================

Sendmail masquerade outgoing email address:

Purpose: to send mail third party domain.

1. Login to Server
2. goto cd /etc/mail
3. take backup copy of sendmail.mc
4. edit below code in file  and uncomment it.
# vim sendmail.mc 

149 FEATURE(`accept_unresolvable_domains')dnl
155 LOCAL_DOMAIN(`localhost.localdomain')dnl
160 MASQUERADE_AS(`domain.com')dnl            
164 FEATURE(masquerade_envelope)dnl
168 FEATURE(masquerade_entire_domain)dnl
170 MASQUERADE_DOMAIN(domain.com)dnl
174 MAILER(smtp)dnl
175 MAILER(procmail)dnl


or  mention specific domain name

MASQUERADE_AS(cyberciti.biz)dnl
FEATURE(masquerade_envelope)dnl
FEATURE(masquerade_entire_domain)dnl
MASQUERADE_DOMAIN(cyberciti.biz)dnl

:wq

# m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
# /etc/init.d/sendmail restart


# mailx namdev.rathod@example.com


Ref:

http://www.cyberciti.biz/tips/sendmail-masquerading-configuration-howto.html

No comments: