Oracle Cloud Infrastructure Documentation

Integrating Sendmail with Email Delivery

Configure Sendmail to Send Email Through Email Delivery

You can use Sendmail to send emails through Email Delivery. Before you use Sendmail you must configure Oracle Cloud Infrastructure Email Delivery in your Sendmail application.

Note

The steps below are for configuring Sendmail to send email via Oracle Cloud Infrastructure Email Delivery. These steps were tested on an Ubuntu 18.04 compute instance.

To enable Sendmail to integrate with Email Delivery:

  1. Make sure Email Delivery is configured to send email. See Getting Started with Email Delivery.

Note

SMTP credentials are required to configure Sendmail to use Email Delivery. Be sure to note the user name and password when you generate the SMTP credentials.

  1. Run the following update and install commands:

    sudo apt update
    sudo apt install sendmail
    sudo apt install m4
  2. In a file editor such as vi, update /etc/mail/authinfo.
    Run the following command:

    sudo vi /etc/mail/authinfo
    Note

    If /etc/mail/authinfo doesn't exist, you can create it by running the command sudo vi /etc/mail/authinfo.

    Add the following line:

    AuthInfo:<SMTP connection endpoint> "U:root" "I:<username from smtp credentials>" "P:<password from smtp credentials>" "M:PLAIN"

    #write and quit file
    :wq!
  3. Generate the /etc/mail/authinfo.db file.

    Run the following command:

    sudo sh -c 'makemap hash /etc/mail/authinfo.db < /etc/mail/authinfo'
  4. Add support for relaying to the Oracle Cloud Infrastructure Email Delivery SMTP endpoint.

    Run the following command:

    sudo sh -c 'echo "Connect:<SMTP connection endpoint> RELAY" >> /etc/mail/access'
  5. Regenerate /etc/mail/access.db.

    Run the following command:

    sudo sh -c 'makemap hash /etc/mail/access.db < /etc/mail/access'
  6. Create a backup of the sendmail.cf and sendmail.mc files.

    Run the following command:

    sudo sh -c 'cp /etc/mail/sendmail.cf /etc/mail/sendmail_cf.backup && cp /etc/mail/sendmail.mc /etc/mail/sendmail_mc.backup'
  7. Update the /etc/mail/sendmail.mc file.

    Run the following command:

    sudo vi /etc/mail/sendmail.mc

    Find the MAILER() definitions.

    Type /MAILER and press ENTER.

    In Insert mode, add the following settings before any MAILER() definitions:

    define(`SMART_HOST', `<SMTP connection endpoint>')dnl
    define(`RELAY_MAILER_ARGS', `TCP $h 25')dnl
    define(`confAUTH_MECHANISMS', `LOGIN PLAIN')dnl
    FEATURE(`authinfo', `hash -o /etc/mail/authinfo.db')dnl
    MASQUERADE_AS(`<sending_domain>')dnl
    FEATURE(masquerade_envelope)dnl
    FEATURE(masquerade_entire_domain)dnl

    Disable Insert mode.

    Run the following command:

    #write and quit file
    :wq!
  8. Make Sendmail writeable.

    Run the following command:

    sudo chmod 666 /etc/mail/sendmail.cf
  9. Regenerate sendmail.cf.

    Run the following command:

    sudo sh -c 'm4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf'
    Note

    If you receive an error, such as "Command not found" or "No such file or directory," confirm that the m4 and sendmail packages are installed on your system.

  10. Reset permissions for sendmail.cf to read only.

    Run the following command:

    sudo chmod 644 /etc/mail/sendmail.cf
  11. Restart Sendmail.

    Run the following command:

    sudo /etc/init.d/sendmail restart
  12. Test the configuration by sending a test email.

    Run the following command:

    /usr/sbin/sendmail -vf <from_email_address> <recipient_email_address>

    Enter the details of the email. After each line press Enter.

    For example:

    From: <from_email_address>
    To: <recipient_email_address>
    Subject: OCI Email Delivery test email
    This is a test message sent from OCI Email Delivery using Sendmail.

    Press Ctrl + D to send the email.

  13. Verify receipt of the test email.

    Note

    You can troubleshoot an issue by reviewing the Sendmail log on your mail server, located at /var/log/mail.log.

More Information