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 sentAm I expected to install sendmail in order to use heirloom-mailx?
2 Answers
I solved installing sendmail:
$ sudo apt-get install sendmailOnce sendmail was installed, I edited /etc/hosts as follows, adding a valid domain:
127.0.1.1 ubuntu example.orgThen I used the following command to reconfigure sendmail:
$ sendmailconfigNow 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_ADDRESSUsing 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 2