Using Centos 5.4, with Postfix. I can do a
mail foo@gmail.com
subject: blah
test
.
Cc:
and the msg gets sent to gmail, but it resides in the spam folder, which is to be expected.
My goal is to be able to generate email msgs, and to have them appear in the regular Inbox! As I understand Postfix/Gmail, it's possible to configure Postfix to send/relay mail via the authenticated/valid user using port 587, which would no longer have the mail be seen as spam.
I've tried a number of parameters based on different sites/articles from the 'net, with no luck. Some of the articles, actually seem to conflict with other articles! I've also looked over the stacflow postings on this, but i'm still missing something… Also talked to a few people on IRC (Centos/Postfix) and still have questions..
So, i'm turning to Serverfault, once again!
If there's someone who's managed to accomplish this, would you mind posting your main.cf, sasl-passwd, and any other conf files that you use to get this working! If I can review your config files, I can hopefully see where I've screwed up, and figure out how to correct the issue.
Thanks for reading this, and any help/pointers you provide!
ps, If there is a stackflow posting that speaks to this that I may have missed, feel free to point it out to me!
-tom
Best Answer
While I haven't tried to relay through a provider using the submission port (587) it should be possible. To enable Postfix to relay you'll need to setup a file with the authenticated credentials to use and make some modifications to your
/etc/postfix/main.cf
config file.The first is the authentication credentials. For this I simply use
/etc/postfix/sasl_passwd
which I add the appropriate line using the template:You'll want to be sure this file is protected so I recommend
root:root
ownership and0600
permissions be set on it. You'll then want to run the following to create the hash mapped version as root.With this out of the way turn your attention go the
/etc/postfix/main.cf
you may find some of the values already set so you will need to change them accordingly but the important details are as follows:These will enable Postfix to be able to use the sasl_passwd file to authenticate when sending mail. You'll then need to tell Postfix it should use the provider to send the mail by adding the configuration
By default Postfix assumes port 25 if you don't specify and this has worked for me in the past. With your requested setup you'll need to specify 587 as the port. With that said I'm not sure if you'll need to modify the sasl_passwd entry to be
smtp.provider.com:587
instead of simplysmtp.provider.com
as I've not tried doing this over a non-default port before so you'll have to try it for yourself.These configuration steps alone are handling mail forwarding on several servers I maintain through a central mail server.
Updated to include fully working example
It actually turns out I'd configured my Ubuntu (Debian-based) laptop to use port 587 on my email provider (not-Gmail) as my DSL provider blocks outbound port 25 traffic. I updated to use one of my Gmail accounts to send mail out instead. The only change I needed to make
I'm obscuring the private data but otherwise pasting as-is working configuration for Postfix.
First we have
/etc/postfix/main.cf
:Next we have
/etc/postfix/sasl_passwd
:I then ran the following SMTP session:
Then I log into my
myotherusername
Gmail account and read the message:Now having shown my 13 years as a systems administrator are not wasted I have email sending from my laptop through Gmail without having any need to generate a self-signed x.509 certificate as others would tell you. The key addition to the
/etc/postfix/main.cf
is the smtp_tls_security_level setting to may to tell Postfix that it is okay to issue the STARTTLS command when connecting to another MTA if it supports TLS. If you forget the smtp_tls_security_level setting you may see an entry in your/var/log/mail.log
along the lines of:However with it set properly you should see something along the lines of: