need postfix changes for using gmail?

13 posts / 0 new
Last post
#1 Tue, 04/19/2011 - 15:22
unsalkorkmaz

need postfix changes for using gmail?

Hi, I am trying to setup gmail as my mail hosting for ALL domains i have. I dont want to host any mail in my server. So, i disabled Mail for domain

but i found this site: http://www.vyoufinder.com/wordpress/?p=37

enable transport mapping in Postfix by editing /etc/postfix/main.cf adding or
changing your configuration with regard to the following. 
To avoid entering a variable twice, search your existing main.cf file for variables you are adding. 
If you find one that exists already, just change it to match the new value as shown below. 
In the end, your main.cf file needs to contain the following:

smtp_sasl_auth_enable = yes

smtpd_sasl_local_domain = $myhostname

smtp_sasl_security_options = noanonymous

# smtp_sasl_security_options =

smtp_sasl_tls_security_options = noanonymous

smtpd_sasl_application_name = smtpd

# Disable DNS Lookupsdisable_dns_lookups = yes
# Optional Address Mapping

# for example may mdawg@localhost to mdawg@gmail.com

relayhost = [smtp.gmail.com]:587

transport_maps = hash:/etc/postfix/transport
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_tls_per_site = hash:/etc/postfix/tls_per_site

# smtp_generic_maps = hash:/etc/postfix/generic

# Postfix 2.3 and later

# smtpd_tls_security_level = may
smtpd_tls_security_level = encrypt
# Obsolete, but still supported
# smtpd_enforce_tls = yes

# this is required to force the servers certification to be checked

smtpd_tls_ask_ccert = yes

Next create 3 new files:

/etc/postfix/transport
/etc/postfix/sasl_passwd
/etc/postfix/tls_per_site

Contents of /etc/postfix/transport:

    # Contents of /etc/postfix/transport    #

# This sends mail to Gmail

gmail.com               smtp:[smtp.gmail.com]:587

Contents of /etc/postfix/sasl_passwd:

    # Contents of sasl_passwd    #

[smtp.gmail.com]:587              youremailname@gmail.com:yourpassword

Contents of /etc/postfix/tls_per_site:

    # Contents of /etc/postfix/tls_per_site    # REMEMBER: After changes run:

#    postmap /etc/postfix/tls_per_site

smtp.gmail.com         MUST

as root, Run postmap on the three files you just created:

# postmap /etc/postfix/transport
# postmap /etc/postfix/sasl_passwd
# postmap /etc/postfix/tls_per_site

Edit etc/postfix/master.cf and add:

   smtp      unix  -       -       n       -       -       smtp
   relay     unix  -       -       n       -       -       smtp

are these changes need? or?

Tue, 04/19/2011 - 16:35
andreychek

Hmm, it's possible that would work, but that also takes some extra steps that you may not need (that makes the configuration more complex).

If all you need is for email to end up at Gmail, then you can accomplish that by simply setting up an MX record for your various domains that points to Gmail's servers.

-Eric

Tue, 04/19/2011 - 19:09
unsalkorkmaz

well, i see i cant send mail from server atm. What i need to activate for allowing sending mail from server too? do i need to install sendmail or?

Tue, 04/19/2011 - 19:14
andreychek

What happens if you try to send mail from the server? What problems are you running into?

-Eric

Tue, 04/19/2011 - 19:45
unsalkorkmaz

well.. nothing happens.. but i can see mail queue in webmin->postfix->mail queue and when try to flush:

Forcing the attempted delivery of mail with the command /usr/sbin/postqueue -c /etc/postfix -f ..

postqueue: warning: unable to look up public/qmgr: No such file or directory postqueue: fatal: Cannot flush mail queue - mail system is down

Tue, 04/19/2011 - 20:00
andreychek

Howdy,

Ah, so it sounds like something isn't working right with Postfix.

Try logging into your server over SSH as root, and restart Postfix using:

/etc/init.d/postfix restart

After you do that -- do any errors show up in the mail logs... either /var/log/maillog, or /var/log/mail.log?

-Eric

Tue, 04/19/2011 - 20:07
unsalkorkmaz
Apr 20 04:06:25 pro1965 postfix/postfix-script: fatal: the Postfix mail system is not running
Apr 20 04:06:30 pro1965 postfix/postfix-script: fatal: the Postfix mail system is not running
Apr 20 04:06:30 pro1965 postfix/postfix-script: starting the Postfix mail system
Apr 20 04:06:30 pro1965 postfix/master[6865]: fatal: bind 0.0.0.0 port 25: Address already in use
Tue, 04/19/2011 - 20:32
andreychek

Hmm, that's an unusual problem.

Have you made any changes to the mail system on your server? Or perhaps installed a different mail service other than Postfix?

What does this command show:

netstat -anpl | grep :25

Wed, 04/20/2011 - 04:02
unsalkorkmaz
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      3182/exim
tcp        0      0 ::1:25                      :::*                        LISTEN      3182/exim
Wed, 04/20/2011 - 04:08
unsalkorkmaz

i used

service exim stop
chkconfig exim off
/etc/init.d/postfix restart

it seems working now.. but.. how can exim be installed?

Wed, 04/20/2011 - 04:24
unsalkorkmaz

hmm.. seems it was already installed on centos 5.6 minimal

Wed, 04/20/2011 - 08:41
andreychek

I don't believe Exim is the default MTA on CentOS, so somehow it got enabled along the way :-)

I believe "Sendmail" is the default MTA on CentOS 5.x. They'll be moving to using Postfix as the default on CentOS 6.

In any case, I'm glad that you got it working now!

-Eric

Fri, 04/29/2011 - 13:55
unsalkorkmaz

Topic locked