0

I'm trying to set up a type of notification system that will alert me when my website is down using crontab and mailx. I went ahead and installed mailx on my server and then tried to send a simple test email by doing: mail -s "Testing" myemail.com < /dev/null, but I receive nothing in my inbox. The only message I see after entering that command is mailx saying that the body is null, which is completely fine for this situation.

I started looking online and noticed that for mailx to work I need to setup an MTA using something like mutt or postfix, but my server is already configured with postfix so I would think that this would have gave me an error upon sending the email.

I really don't know much about mailx or postfix for that matter so it's a little difficult for me to debug this issue when there aren't any errors occurring. If anyone knows why this would be happening, I would greatly appreciate it. Thanks!

Michael
  • 101

1 Answers1

0

If the message is successfully passed off to postfix, there will be no immediate error. Check mailq to see if the message is still in the mail queue, and look at /var/log/maillog (or equivalent) for delivery errors.

There could be many reasons why the message is not being delivered. Two of the most common ones are (a) that your service provider blocks outbound mail connections in order to prevent spam, or (b) your mail provider is blocking connections from your server because it is a potential spam source, e.g. that IP address has been used for spam in the past and is on a blacklist. You would need to check the logs in order to diagnose.

More generally, why not use a service like UptimeRobot or Hetrix Tools which do this and have a free tier?

tater
  • 1,395
  • 2
  • 9
  • 12
  • when checking mailq, it says that the mail queue is empty. Also there is nothing inside the maillog file. I believe I'm just using localhost for postfix and not an actual mail server. – Michael Aug 03 '20 at 15:41