I installed the heirloom-mailx package and tried to use mailx to send an email:

$ echo "heirloom mailx works!" | mailx -s "Server mail" 

However the operation did not succeed:

Cannot start "/usr/sbin/sendmail": executable not found (adjust *sendmail* variable) "/root/dead.letter" 6/136 ... message not sent 

Am I expected to install sendmail in order to use heirloom-mailx?

2 Answers

I solved installing sendmail:

$ sudo apt-get install sendmail 

Once sendmail was installed, I edited /etc/hosts as follows, adding a valid domain:

127.0.1.1 ubuntu example.org 

Then I used the following command to reconfigure sendmail:

$ sendmailconfig 

Now I am able to send emails from my server.

Am I expected to install sendmail in order to use heirloom-mailx?

No, but you need a mail service. hierloom-mailx can be set up to use SMTP:

Supports SMTP to send messages directly to a remote server. A local sendmail interface setup is thus not necessary. In combination with OpenSSL or NSS, both the STARTTLS method and SMTPS can be used. SMTP AUTH is also supported.

You will need to configure heirloom-mailx though.


Using SMTP

mailx -v -s "$EMAIL_SUBJECT" \ -S smtp=smtp://smtp.server.com -S from="$FROM_EMAIL_ADDRESS($FRIENDLY_NAME)" \ $TO_EMAIL_ADDRESS 

Using gmail:

mailx -v -s "$EMAIL_SUBJECT" \ -S smtp-use-starttls \ -S ssl-verify=ignore \ -S smtp-auth=login \ -S smtp=smtp://smtp.gmail.com:587 \ -S from="$FROM_EMAIL_ADDRESS($FRIENDLY_NAME)" \ -S smtp-auth-user=$FROM_EMAIL_ADDRESS \ -S smtp-auth-password=$EMAIL_ACCOUNT_PASSWORD \ -S ssl-verify=ignore \ -S nss-config-dir=~/.mozilla/firefox/ \ $TO_EMAIL_ADDRESS 

Source

2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy