Integrating Mailx with Email Delivery

Use Mailx to send emails through the Email Delivery service.

Configure Mailx to Send Email Through Email Delivery

Mailx is a UNIX utility program for sending and receiving mail, also known as a Mail User Agent program. You can use Mailx to send emails through Email Delivery. Before you use Mailx, you must configure Oracle Cloud Infrastructure Email Delivery in your Mailx application.

Use these instructions only if no mail transfer agent (MTA), such as Postfix or Sendmail, is in use on the system. If you're configuring an MTA, follow the configuration instructions for that program and leave the Mailx settings at their defaults. This makes Mailx use the local MTA program to send outbound mail.

Important

These instructions contain sample code for your convenience and needs to be used as a reference. For client support, you must contact Mailx customer support.
Note

These steps assume you're signed in to an Oracle Linux instance. Other distributions of Linux might have different commands and file locations. These steps were tested on an Oracle Linux Server release 7.9 compute instance and Mailx version 12.5 7/5/10.

To enable Mailx to integrate with Email Delivery:

  1. Ensure that Email Delivery is configured to send email. See Getting Started.

    Note

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

  2. Update the Mailx mail.rc file.

    To open the mail.rc file, run the following command:

    sudo vi ~/.mail.rc

    Add the following information to the end of the file:

    #smtp config
    
    set nss-config-dir=/etc/pki/nssdb/
    set smtp-use-starttls
    set smtp-auth=plain
    set smtp=<SMTP connection endpoint>:25
    set from=<from_email_address>
    set smtp-auth-user=<OCID from smtp credentials>
    set smtp-auth-password=<password from smtp credentials>
  3. Test the configuration by sending a test email.

    Run the following command:

    echo "Test Email" | mail -v -s "Send an email via mailx" -r "From Name <from_email_address>" <recipient_email_address>

Troubleshooting

"Error in certificate: Peer's certificate issuer has been marked as not trusted" occurs when sending email

To troubleshoot this issue, complete the following steps:

  1. Run the following command to view the certificate chain:
    echo | openssl s_client -starttls smtp -crlf -connect <SMTP-endpoint>:587 -showcerts
    Example output:
    [root@ociuvddatg01 ~]# echo | openssl s_client -starttls smtp -crlf -connect smtp.email.us-ashburn-1.oci.oraclecloud.com:587 -showcerts
              CONNECTED(00000003)
              depth=2 C = US, O = DigiCert Inc, OU = www.digicert.com, CN = DigiCert Global Root G2
              verify return:1
              depth=1 C = US, O = DigiCert Inc, CN = DigiCert Global CA G2
              verify return:1
              depth=0 C = US, ST = California, L = Redwood City, O = Oracle Corporation, OU = Oracle OCI-PROD ASHBURN, CN = smtp.email.us-ashburn-1.oci.oraclecloud.com
              verify return:1
               ---
             Certificate chain
     0 s:/C=US/ST=California/L=Redwood City/O=Oracle Corporation/OU=Oracle OCI-PROD ASHBURN/CN=smtp.email.us-ashburn-1.oci.oraclecloud.com
       i:/C=US/O=DigiCert Inc/CN=DigiCert Global CA G2
     1 s:/C=US/O=DigiCert Inc/CN=DigiCert Global CA G2
       i:/C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert Global Root G2
     2 s:/C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert Global Root G2
       i:/C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert Global Root G2
    ---
    Server certificate
    -----BEGIN CERTIFICATE-----
    ......
    -----END CERTIFICATE-----
    ......
  2. Extract the certificate that signed your domain. In this example, this is the last certificate (2 s:/C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert Global Root G2). Copy and paste the certificate into a separate DigiCert.pem file, including the BEGIN CERTIFICATE and END CERTIFICATE fields.
  3. Install the certificate into the Centos NSSDB database. Replace "DigiCert Global Root G2" in the following example with your certificate:
    sudo certutil -A -t "C,," -n "DigiCert Global Root G2" -d /etc/pki/nssdb/ -i DigiCert.pem
    To view the certificate, use the following command:
    sudo certutil -L -d /etc/pki/nssdb/

More Information

For network security services, see the Mailx documentation.