What did I miss-configure to be getting MAILER-DAEMON errors?
(I was trying to keep this post short, but it got a bit out of hand.)
I am setting up an email alert system for when my RAID1 should go down.
I installed nullmailer as MTA on Ubuntu 19.10, and followed these instructions to do that.
nullmailer
should send an alert email to alert_recipient@example.com using an external mail server at smtp.external_email_server.com.
My smpt account with the external mail provider is me@my_domain_hosted_by_provider.com
It looks like nullmailer
is able to relay the email to the external email provider, but the delivery from there is getting sender rejected error:
Diagnostic-Code: SMTP; 550 5.1.0 root@external_email_server.com sender rejected (497)
I've noticed that there is no problem sending and receiving emails if I edit the nullmailer
generated file in the queue from:
me@localhost
alert_recipient@example.com
...
to
me@my_domain_hosted_by_provider.com
alert_recipient@example.com
...
It looks like maybe this nullmailer Rewrite Wrapper could do this, but I am hoping for something more intuitive.
The /etc/nullmailer/allmailfrom
answer to this, found here or here is a way to override this issue, but what if one has more then one SMTP provider?
To test nullmailer
email delivery I use
echo "error" | NULLMAILER_NAME="Testsytem check" mail
-s "This is just a test with nullmailer" "alert_recipient@example.com"
The above test generates this reject alert email from "Message Delivery Subsystem" MAILER-DAEMON@external_email_server.com:
The message attached below could not be delivered to one or
more of the intended recipients:
<alert_recipient@example.com>
Reporting-MTA: x-local-hostname; external_email_server.com
Arrival-Date: Wed, 11 Mar 2020 10:49:26 -0700
Final-Recipient: rfc822; alert_recipient@example.com
Action: failed
Status: 5.1.0
Last-Attempt-Date: Wed, 11 Mar 2020 10:49:26 -0700
Remote-MTA: dns; smtp.external_email_server.com
Diagnostic-Code: SMTP; 550 5.1.0 <root@external_email_server.com> sender rejected (497)
I believe that maybe somehow the sender "root@external_email_server.com" should be instead "me@my_domain_hosted_by_provider.com" (not sure.)
And, (somewhat unrelated, but not sure) I am also getting this *Failed to start Nullmailer** in the /var/log/syslog
entries, when restarting nullmailer
with sudo service nullmailer restart
:
Mar 11 10:49:29 localhost systemd[1]: Stopped Nullmailer relay-only MTA.
Mar 11 10:49:29 localhost systemd[1]: nullmailer.service: Start request repeated too quickly.
Mar 11 10:49:29 localhost systemd[1]: nullmailer.service: Failed with result 'start-limit-hit'.
Mar 11 10:49:29 localhost systemd[1]: Failed to start Nullmailer relay-only MTA.
When testing mdadm mailing alerts I am using this, which somehow stragely puts a total of out 3 emails in the queue. And, what is strange is that it looks like the queue only gets processed when nullmailer
gets restarted:
sudo mdadm --monitor --scan --test -1
SETUP
nullmailer
At first I was using /etc/nullmailer/me
with
external_email_server.com
but this gave me a warning in the error log /var/log/mail.log
Warning: On Debian systems, nullmailer's 'me' is disregarded; please use '/etc/mailname' instead.
So I deleted the file /etc/nullmailer/me
and instead am using /etc/mailname
with the value:
external_email_server.com
/etc/nullmailer/defaulthost is also set to
external_email_server.com
/etc/nullmailer/adminaddr
me@my_domain_hosted_by_provider.com
mdadm configuration
I followed these instructions.
/etc/mdadm/mdadm.conf
...
# automatically tag new arrays as belonging to the local system
HOMEHOST <system>
# instruct the monitoring daemon where to send mail alerts
# is defined in /etc/aliases so no need to use MAILADDR
MAILADDR alertrecipient@examplesomewhereelse.com
MAILFROM me@my_domain_hosted_by_provider.com
...
/etc/aliases
root: alertrecipient@examplesomewhereelse.com
postmaster: alertrecipient@examplesomewhereelse.com
default: alertrecipient@examplesomewhereelse.com