User Tools

Site Tools



Sendmail - the default mailing system on Linux Computers

Php's mail() function uses sendmail. However what if sendmail is broken, or php's mail() is broken.

Here is how to send an email using sendmail on the command line: /usr/lib/sendmail email@address type in message then and type some more To send email press CTRL+D

There are a host of options including debug etc.

Relaying Unix/ Linux PHP mail() via an external smtp server ->

If your Web Server IP is listed as SPAM then you need to use a proper mailserver to “relay” your emails. We dont want to have to go writing TONS of code for PHP to replace the mail() function. Here's how you can tell sendmail to relay via a SMTP server :-

Setup your own (config) file. Here is the Important Line: O QueueDirectory=/var/tmp

DS - obviously - set your SMTP server Here. Also the QueueDirectory has to be set to something sendmail can write to. The quickest to spool the mails is /var/tmp

In order to get PHP to use your (config), we'll use a htaccess file. Place this in your .htaccess file: php_value mail.force_extra_parameters “-C /path_to_your/”

Do a phpinfo() in your Directory to check that the extra_parameters register. Well - you should hopefully be off then.

Proper Domain Name

If you are finding that your emails are been bounced back saying localhost.localdomain is not valid etc. then your email sendmail is not setup correctly. A quick and dirty solution to this is to add/ replace the following line into or # my official domain name # … define this only if sendmail cannot automatically determine your domain Your emails will be send as instead of www@localhost.localdomain.

Info. found at:

sendmail.txt · Last modified: 2022/07/19 21:13 by