Weird behaviour with sendmail, Apache and PHP

What I'm trying to do is to simply make the mail() function of PHP work flawlessly.

I've installed sendmail with

apt-get install sendmail

It installed without any problems and auto-configured everything.

The weirdness starts here. I've created a simple php file to test it.

The contents are as follows:

Now, the mail successfully arrives at the destination, no problem there. But the php script never gets terminated. It just keeps running and running until the process is automatically killed. Then the page displays a "500 Internal Server Error".

I do know a few things about sendmail, but never encountered an error like this before. Any ideas? Thanks!

1 Reply

I've found the solution and I'm writing it here for future reference.

The problem was that I haven't set an FQDN (Fully Qualified Domain Name) in /etc/hosts. The file's first two lines were like this:

127.0.0.1 localhost
127.0.0.1 [your host name]

I've changed it to this:

127.0.0.1 localhost localhost.localdomain [your host name]
127.0.0.1 [your host name]

Then I've executed sendmailconfig and voila! Everything worked flawlessly!

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct