Basic Sendmail Troubleshooting on a Laravel Forge Server

If you’re using PHP and localhost mail delivery on a Laravel Forge server, at times emails might not arrive at the recipient.

Although you can troubleshoot /var/log/mail.log, the Sendmail messages aren’t always the same response as the email server.

For example, you might be blocked by a spam blocking service, and the error appearing in the Sendmail log file doesn’t show it.

How to test sending email from localhost to a remote mail server

Here is a command to test sending email from the command line using Sendmail. The magic lies in the command line options which shows an extra level of verbosity. Be sure to also tail the log file as well to see additional messages.

echo -e "To: [email protected]\nSubject: Test\nTest\n" | sendmail -bm -t -v

In one specific instance, Outlook 365 returned “User Unknown” in the log file, but doing the above command showed that actually the email server was returning a Spam blocking message.

What if message are from “server.localdomain”?

You might also run into a problem where the log file doesn’t show your originating domain, and instead reports the FROM: address as server.localdomain. To correct this problem, please see this reference which explains that you have to update /etc/hosts.



Share this article

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top