[wplug] Mail server question - not dumb ;-p

Keir Josephson kjoseph at stargate.net
Thu Jun 19 23:45:18 EDT 2003


> What PHP actually does is call a commandline program and passes the data
> on to that. Often that commandline program is /usr/sbin/sendmail or
> similar. I'm fairly sure that the popular sendmail replacements offer a
> sendmail like tool for compatibility reasons.
> (It's nice being first to market.)
>
>
> -james


This looks like the right track. I haven't had the pleasure to work with
the php mail function, yet, but I'm pretty sure you don't need to have a
sendmail server running on your box to send the mail out. I'd actually
recommend against it on a web server unless you need it for other reasons,
such as receiving mail for your domain and you don't have another real IP
to use on a separate machine.

Just a suggestion, but it's best to relay your mail through your ISP's
mail server. If you send mail through a local sendmail server, you have to
deal with the fact that many other mail servers are set up to reject mail
if your not a registered mail record for the domain your on. If you get
that fixed, then you have to deal with spammers potentially trying to use
your box as a relay for their junk mail. Not to mention receiving spam on 
your box.

As James said, the mail() function automatically tries to use the
/usr/sbin/sendmail command to send the mail. The sendmail command is
actually a server and client. To start the server, you just run something
like sendmail -bd (to run as a daemon which listens on port 25 by default)  
otherwise it just runs to send the specific mail request then quits. I
don't believe that the server needs to be listening on port 25 for this to
occur.

However, in both cases sendmail uses the sendmail.cf file to determine how
to deliver the mail appropriately. These files are usually under
/etc/mail. In older versions of sendmail the sendmail.cf file is there to.  
In later versions, though, the .cf file has been moved to /etc and there
is a sendmail.mc file under /etc/mail. If this is what you have, edit the
.mc file and add this line:

define(`SMART_HOST', `[<your isp's outgoing mail server>]')dnl

then run:

m4 /etc/mail/sendmail.mc > /etc/sendmail.cf

or something to that effect. This will update the .cf file with a smart 
relay. That will send all mail that isn't local to this server (such as 
root at localhost) out to the outgoing mail server of your ISP. 

If you have an older version, look for the DS line in the .cf file and 
modify it to be:

DS[<your isp's outgoing mail server>]


Hope this helps.

-Keir






More information about the wplug mailing list