sendmail

How to setup or configure sendmail in ubuntu 22.04 with custom smtp relay


When I searched for configuring sendmail on ubuntu I din't get any clear answer, each of them assume I know what they are talking about,

I just wanna know how to configure sendmail with custom smtp relay, like smtp-relay.brevo.com and how to test it

Thanks


Solution

  • Need port 25 dan 587 if you using docker container

    1. apt install sendmail sendmail-bin mailutils
    2. mkdir -m 700 /etc/mail/authinfo
    3. nano /etc/mail/authinfo/smtp-auth
    AuthInfo:smtp-relay.brevo.com  "U:your-email" "P:your-smtp-key"
    
    1. makemap hash /etc/mail/authinfo/smtp-auth < /etc/mail/authinfo/smtp-auth
    2. chmod 600 /etc/mail/authinfo/smtp-auth.db
    3. nano /etc/mail/sendmail.mc
    ....
    dnl #
    dnl # Defining Gmail Smarthost for sendmail
    define(`SMART_HOST',`[smtp-relay.brevo.com]')dnl
    define(`RELAY_MAILER',`esmtp')dnl
    define(`RELAY_MAILER_ARGS', `TCP $h 587')dnl
    define(`ESMTP_MAILER_ARGS', `TCP $h 587')dnl
    define(`confAUTH_OPTIONS', `A p')dnl
    TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
    define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
    FEATURE(`authinfo',`hash -o /etc/mail/authinfo/smtp-auth.db')dnl
    dnl #
    dnl # Default Mailer setup
    MAILER_DEFINITIONS
    MAILER(`local')dnl
    MAILER(`smtp')dnl
    
    1. make -C /etc/mail
    2. service sendmail reload
    3. echo "This is a test for sendmail gmail relay" | sendmail your-email@gmail.com