gmail, postfix and php mail script

I have multiple domains. I have Gmail to send and receive mail for each domain. How do I configure Postfix to simply send the contents of a php mail script to info@domain1.com, info@domain2.com, and so on? I'm using Ubuntu. There has to be an easy but secure way. Thanks very much.

5 Replies

This document covers setting up Postfix as a "null client" (send-only server). Another discusses client authentication.

Once configured you can feed a message (with To: and Subject: headers) to 'sendmail -t' to test it. If that works, PHP should be able to send mail.

Postfix may be overkill for what you are doing - something like ssmtp might do all you need:

http://packages.ubuntu.com/hardy/ssmtp

Thanks for responding to my question. I've gotten Postfix to work. But I'll be looking at the ssmpt solution to see if that's a better fit.

I do appreciate the answers and the help.

I've got mine set up so that php uses msmtp to send mail through Google via TLS. I used the following guide to set that up:

http://nanotux.com/blog/the-ultimate-server/4/#l-mail

The only problem I had was that no matter how many times I changed php.ini, php just wouldn't take my sendmail override. The phpinfo() function said that it was using the ini I was editing, but it just wouldn't take. I think I restarted lighttpd a million times.

So finally I just set up a symbolic link where php wanted to use sendmail to point to msmtp. It's none the wiser.

It works well, but it is a little slow. Whenever a user leaves a comment there is a noticeable delay while it connects securely to google and sends the mail.

It's not an unbearable delay, but it's slower than the rest of my site.

.

Another gotcha with ssmtp besides the one Lykaon noted is that while the generic PHP mail function pipes messages to sendmail, some software (I'm looking at you, PunBB) does not and expects to contact an SMTP server. If whatever you are using is this way, ssmtp won't help (guess how I discovered this!). On the other hand, if what you're using supports SMTP authentication, you might be able to configure it to contact Gmail directly and cut out the middleman.

But if you can live with these, ssmtp (or msmtp) do the job just fine and are simpler to set up than a full MTA.

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