How to configure php.ini with remote SMTP?

My choice is setup a postfix server in the same web server that sent mail only for localhost and with this setting in main.cf to use a remote SMTP server:

relayhost = [a.b.c.d]

It works for me.


It's not possible, AFAIK. I would either:

  1. Use a fuller functioning mail class such as PEAR::Mail.
  2. If all mail from that machine should be smart-relayed then consider configuring SSMTP as your sendmail binary.

msmtp can be used as an alternative to sendmail which simply forwards traffic directly to an external SMTP server. It's pretty easy to set up and works very well.


You can either use PHP's inbuilt IMAP tools or the very handy PHPMailer

This could be better answered on Stack Overflow I fear...