• VMware

    Learn about VMware virtualization for its products like vsphere ESX and ESXi, vCenter Server, VMware View, VMware P2V and many more

  • Linux

    Step by step configuration tutorials for many of the Linux services like DNS, DHCP, FTP, Samba4 etc including many tips and tricks in Red Hat Linux.

  • Database

    Learn installation and configuration of databases like Oracle, My SQL, Postgresql, etc including many other related tutorials in Linux.

  • Life always offers you a second chance ... Its called tomorrow !!!

    Thursday, August 09, 2012

    How to configure Sendmail server in Red Hat Linux

    Let me show you simple steps to configure a sendmail server which will use external smtp server to send mails across the network.

    IMPORTANT NOTE:
    Please make sure that this will NOT act as a smtp server instead it will send mails using smtp.gmail.com. You will be able to send mails on any address over the internet using your local linux box mail address but you won't be able to receive any of the mails from outside domain.
    NOTE: This is a simple configuration but if you want to insert some special permissions and authentications let me know I will try to help with additional info.

    To start of  with the configuration initially you need to check for the presence of STARTLS and SASLv2 in your machine.
    # sendmail -d0.1 -bv root
    Version 8.13.8
    Compiled with: DNSMAP HESIOD HES_GETMAILHOST LDAPMAP LOG MAP_REGEX
    MATCHGECOS MILTER MIME7TO8 MIME8TO7 NAMED_BIND NETINET NETINET6
    NETUNIX NEWDB NIS PIPELINING
    SASLv2 SCANF SOCKETMAP STARTTLS
    TCPWRAPPERS USERDB USE_LDAP_INIT
    ============ SYSTEM IDENTITY (after readcf) ============
    (short domain name) $w = server
    (canonical domain name) $j = server.example.com
    (subdomain name) $m = example.com
    (node name) $k = server.example.com
    ========================================================

    # yum -y install sendmail
    # rpm -qa | grep sendmail
    sendmail-cf-8.13.8-2.el5
    sendmail-8.13.8-2.el5

    make sure that you install sendmail-cf because while mapping sendmail.mc into sendmail.cf you need sendmail-cf as mentioned in the configuration file


    # vi /etc/mail/sendmail.mc
    define(`SMART_HOST', `smtp.gmail.com')dnl

    # (add these two lines in your sendmail.mc file to listen on port 465 and 587)
    define(`RELAY_MAILER_ARGS', `TCP $h 587')dnl
    define(`ESMTP_MAILER_ARGS', `TCP $h 587')dnl

    # uncomment this line
    TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
    define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl

    # add this line
    FEATURE(`authinfo', `hash /etc/mail/auth/client-info.db')dnl
    FEATURE(`access_db', `hash -T<TMPF> -o /etc/mail/access.db')dnl
    DAEMON_OPTIONS(`Port=smtp, Name=MTA')dnl

    # uncomment for sendmail to listen on port 587
    DAEMON_OPTIONS(`Port=submission, Name=MSA, M=Ea')dnl

    # uncomment for sendmail to listen on port 587
    DAEMON_OPTIONS(`Port=smtps, Name=TLSMTA, M=s')dnl 

    # write your domain and uncomment
    MASQUERADE_AS(`mydomain.com')dnl


    Make a directory auth inside /etc/mail and assign proper permissions to auth so that no other user can access this directory
    # mkdir /etc/mail/auth
    # cd /etc/mail/auth

    Create a new file client-info
    # vi client-info
    AuthInfo:gmail.com "U:username" "P:Password" "M:PLAIN"
    AuthInfo: "U:username" "P:Password" "M:PLAIN

    # makemap -r hash client-info.db < client-info
    # vi /etc/mail/access
    Connect:your-ip RELAY

    # m4 sendmail.mc > sendmail.cf
    # service sendmail restart
    # sendmail -v user@domain.com

    NOTE: If you get any error message or you are unable to send mails even after following the above configuration kindly revert back with the log messages so that I can help you further for the same.

    Follow the below topics for more tutorials:


    0 comments:

    Post a Comment