0
I want to send mails from a bash script and to know that they sucessfully left my server.
There are many ways to send mails from bash (see 1 2 for more possibilities). A common way is to use mail
or mutt
together with the build-in MTA (e.g. postfix
). If one does not run a "true" mailserver, than postfix can be configured as a "smart host" or "satelite system" where it connects to another SMTP server (the so-called relay) and sends everything over this server.
I can assume any MTA. Since I control the server, I am willing to install any MTA which is easy to maintain = has an ubuntu (18.04 LTS and newer) and centos (7.4 and newer) package. Right now I am using postfix, since I know it okay and the setup as a relay is quite simple.
Assuming such a setup, I want to write a bash script which sends a mail and then awaits the confirmation that sending it to the relay was successfull. My problem is the last part.
echo "hello world" | mail -s "a subject" someone@example.com
#
# Check that the mail has arrived at the relay server. But how?
#
Can you assume that a relay-only MTA such as msmtp will be used, or do you need this to work with any MTA? – user1686 – 2019-05-07T04:48:12.123
I can assume any MTA. Since I control the server, I am willing to install any MTA which is easy to maintain = has an ubuntu (18.04 LTS and newer) and centos (7.4 and newer) package. Right now I am using postfix, since I know it quite okay and the setup as a relay is quite simple. – masgo – 2019-05-07T07:05:48.367
Please edit your question with new information such as the one in your comment; comments are not guaranteed to stick around. – dirkt – 2019-05-07T07:22:18.710