Postfix Email Server using Gmail as the Relay Host or Domain
Wade Smart
wadesmart at gmail.com
Sun Jan 31 01:53:10 UTC 2010
Stifan Kristi wrote:
> Dear all,
>
> Is there anyone know how to configure Postfix to use Gmail as relay host
> or domain?
> I've followed the step by step guided on ubuntu forum but, still can't
> send email.
> Attached the step by step guided configuration, that I've follow.
> Please correct me if i'm wrong.
>
> Thanks and Best Regards,
>
> *Stifan Kristi (Kou Shou)*
> Jakarta, Indonesia
> Tel. +62 21 581 6264 | Cell. +62 818 783 118
> Email : sugizo at japan.com <mailto:sugizo at japan.com>
>
> *スティファン* *クリスティ* *(**黄祥**)*
> ジャカルタ、 インドネシア
> 電話番号。 +六二 二一 五八一 六二六四 | 携帯。 +六二 八一八
> 七八三 一一八
> 電子メール : sugizo at japan <mailto:sugizo at japan.com>。com
>
>
> ------------------------------------------------------------------------
>
> Note :
> - Change IP Address with Your IP
> - Change ubuntu with Your Hostname
> - Change linux.vmw with Your Domain
> - Change ubuntu.linux.vmw with Your FQDN Hostname
> - Change /home/sugizo with Your Directory
> - Change ***** with Your Password
>
> 1. Backup and Edit IP Address Configuration File
> cp /etc/network/interfaces /home/sugizo/bkup/interfaces.ori
> sudo vim /etc/network/interfaces
>
> auto eth0
> iface eth0 inet static
> address 192.168.44.3
> netmask 255.255.255.0
> gateway 192.168.44.2
> network 192.168.44.0
> broadcast 192.168.44.255
>
> auto eth1
> iface eth1 inet static
> address 18.18.18.3
> netmask 255.255.255.0
> gateway 192.162.44.2
> network 18.18.18.0
> broadcast 18.18.18.255
>
> auto eth2
> iface eth2 inet static
> address 88.88.88.3
> netmask 255.255.255.0
> gateway 192.168.44.2
> network 88.88.88.0
> broadcast 88.88.88.255
>
> 2. Backup and Edit Hostname File Configuration
> cp /etc/hostname /home/sugizo/bkup/hostname.ori
> sudo vim /etc/hostname
>
> ubuntu.linux.vmw
>
> 3. Backup and Edit Host Addresses Configuration
> cp /etc/hosts /home/sugizo/bkup/hosts.ori
> sudo vim /etc/hosts
>
> 127.0.0.1 localhost
> 127.0.1.1 ubuntu.linux.vmw ubuntu
> 192.168.44.3 ubuntu.linux.vmw ubuntu
> 18.18.18.3 ubuntu.linux.vmw ubuntu
> 88.88.88.3 ubuntu.linux.vmw ubuntu
>
> 4. Backup and Edit Host Resolve Addresses Configuration
> cp /etc/resolv.conf /home/sugizo/bkup/resolv.conf.ori
> sudo vim /etc/resolv.conf
>
> domain linux.vmw
> search linux.vmw
> nameserver 192.168.44.2
>
> 5. Reboot the Machine
> sudo reboot
> 6. Update and Install Packages
> sudo apt-get update
> sudo apt-get install postfix postfix-tls dovecot-imapd
> dovecot-pop3d dovecot-common dovecot-postfix fetchmail procmail
> amavisd-new spamassassin clamav clamav-base clamav-freshclam
> clamav-daemon freepops squirrelmail apache2 php5 php5-cgi php5-cli
> php5-common libapache2-mod-php5 libnet-dns-perl
> libmail-spf-query-perl pyzor razor arj bzip2 cabextract cpio file
> gzip lha nomarch pax rar unrar unzip zip zoo sasl2-bin
> libsasl2-modules
> 7. Postfix Initialize Configuration:
> OK
> Internet Site
> System mail name : linux.vmw
> 8. Backup and Activate Spam Assassin
> cp /etc/default/spamassassin /home/sugizo/bkup/spamassassin.ori
> sudo vim /etc/default/spamassassin
>
> ENABLED=1
>
> 9. Backup and Edit Spam Assassin
> cp /etc/spamassassin/local.cf /home/sugizo/bkup/local.cf.ori
> sudo vim /etc/spamassassin/local.cf
>
> rewrite_header Subject [SPAM]
> report_safe 2
>
> 10. Add clamav user to the amavis group and vice versa
> sudo adduser clamav amavis
> sudo adduser amavis clamav
>
> 11. Backup and Activate Spam and Anti Virus Detection
> cp /etc/amavis/conf.d/15-content_filter_mode
> /home/sugizo/bkup/15-content_filter_mode.ori
> sudo vim /etc/amavis/conf.d/15-content_filter_mode
>
> @bypass_virus_checks_maps = (
> \%bypass_virus_checks, \@bypass_virus_checks_acl, \$bypass_virus_checks_re);
> @bypass_spam_checks_maps = (
> \%bypass_spam_checks, \@bypass_spam_checks_acl, \$bypass_spam_checks_re);
>
> 12. Backup and Edit Spam Mail Configuration
> cp /etc/amavis/conf.d/20-debian_defaults
> /home/sugizo/bkup/20-debian_defaults.ori
> sudo vim /etc/amavis/conf.d/20-debian_defaults
>
> $final_spam_destiny = D_DISCARD;
>
> 13. Backup and Edit User Domain Configuration
> cp /etc/amavis/conf.d/50-user /home/sugizo/bkup/50-user.ori
> sudo vim /etc/amavis/conf.d/50-user
>
> @local_domains_acl = ( ".$mydomain" );
>
> 14. Backup and Edit Main Postfix Configuration
> cp /etc/postfix/main.cf /home/sugizo/bkup/main.cf.ori
> sudo vim /etc/postfix/main.cf
> 1. Add
>
> mydomain = linux.vmw
> virtual_alias_maps =
> content_filter = smtp-amavis:[127.0.0.1]:10024
> home_mailbox = Maildir/
> inet_protocols = all
> smtpd_sasl_path = private/auth-client
> smtpd_sasl_local_domain = $mydomain
> smtpd_sasl_security_options = noanonymous
> smtpd_sasl_auth_enable = yes
> broken_sasl_auth_clients = yes
> smtpd_sasl_password_maps = hash:/etc/postfix/saslpasswd
> smtpd_always_send_ehlo = yes
> smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination,check_policy_service inet:127.0.0.1:10023
> smtpd_sasl_authenticated_header = yes
> smtpd_tls_auth_only = no
> smtpd_tls_note_starttls_offer = yes
> smtp_tls_note_starttls_offer = yes
> smtpd_tls_CAfile = /etc/postfix/ssl/cacert.pem
> smtpd_tls_loglevel = 1
> smtpd_tls_received_header = yes
> smtpd_tls_session_cache_timeout = 3600s
> tls_random_source = dev:/dev/urandom
>
> 2. Edit
>
> smtpd_tls_cert_file = /etc/postfix/ssl/smtpd.crt
> smtpd_tls_key_file = /etc/postfix/ssl/smtpd.key
> relayhost = [smtp.gmail.com]:587
> mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 192.168.44.0/24 18.18.18.0/24 88.88.88.0/24
>
> 15. Backup and Edit Master Postfix Configuration
> cp /etc/postfix/master.cf /home/sugizo/bkup/master.cf.ori
> sudo vim /etc/postfix/master.cf
>
> pickup fifo n - - 60 1 pickup
> -o content_filter=
> -o receive_override_options=no_header_body_checks
>
> smtp-amavis unix - - - - 2 smtp
> -o smtp_data_done_timeout=1200
> -o smtp_send_xforward_command=yes
> -o disable_dns_lookups=yes
> -o max_use=20
>
> 127.0.0.1:10025 inet n - - - - smtpd
> -o content_filter=
> -o local_recipient_maps=
> -o relay_recipient_maps=
> -o smtpd_restriction_classes=
> -o smtpd_delay_reject=no
> -o smtpd_client_restrictions=permit_mynetworks,reject
> -o smtpd_helo_restrictions=
> -o smtpd_sender_restrictions=
> -o smtpd_recipient_restrictions=permit_mynetworks,reject
> -o smtpd_data_restrictions=reject_unauth_pipelining
> -o smtpd_end_of_data_restrictions=
> -o mynetworks=127.0.0.0/8
> -o strict_rfc821_envelopes=yes
> -o smtpd_error_sleep_time=0
> -o smtpd_soft_error_limit=1001
> -o smtpd_hard_error_limit=1000
> -o smtpd_client_connection_count_limit=0
> -o smtpd_client_connection_rate_limit=0
> -o receive_override_options=no_header_body_checks,no_unknown_recipient_checks
>
> 16. Add SMTP Credential
> sudo vim /etc/postfix/saslpasswd
>
> [smtp.gmail.com]:587 steve.van.christie at gmail.com:*****
>
> 17. Hash /etc/postfix/saslpasswd
> sudo postmap /etc/postfix/saslpasswd
> 18. Edit Postfix SASL
> sudo vim /etc/postfix/sasl/smtpd.conf
>
> pwcheck_method: saslauthd
> mech_list: plain login
>
> 19. Create Certificate for TLS Postfix
> 1. Create STMP TLS Key
> sudo mkdir /etc/postfix/ssl
> cd /etc/postfix/ssl/
> sudo openssl genrsa -des3 -rand /etc/hosts -out smtpd.key 1024
>
> Enter pass phrase for smtpd.key: *****
> Verifying - Enter pass phrase for smtpd.key: *****
>
> 2. Create SMTP CSR
> sudo chmod 600 smtpd.key
> sudo openssl req -new -key smtpd.key -out smtpd.csr
>
> Enter pass phrase for smtpd.key: *****
> Country Name (2 letter code) [AU]:ID
> State or Province Name (full name) [Some-State]:Jakarta
> Locality Name (eg, city) []:Jakarta
> Organization Name (eg, company) [Internet Widgits Pty
> Ltd]:ubuntu
> Organizational Unit Name (eg, section) []:ubuntu
> Common Name (eg, YOUR name) []:ubuntu.linux.vmw
> Email Address []:steve.van.christie at gmail.com
> A challenge password []:*****
> An optional company name []:ubuntu
>
> 3. Create Sign Key Expiration Date
> sudo openssl x509 -req -days 3650 -in smtpd.csr -signkey
> smtpd.key -out smtpd.crt
>
> Enter pass phrase for smtpd.key: *****
>
> 4. Create Open SSL RSA
> sudo openssl rsa -in smtpd.key -out smtpd.key.unencrypted
>
> Enter pass phrase for smtpd.key: *****
>
> 5. Create SSL to PEM CA Certificate
> sudo mv -f smtpd.key.unencrypted smtpd.key
> sudo openssl req -new -x509 -extensions v3_ca -keyout
> cakey.pem -out cacert.pem -days 3650
>
> Enter PEM pass phrase: *****
> Verifying - Enter PEM pass phrase: *****
> Country Name (2 letter code) [AU]:ID
> State or Province Name (full name) [Some-State]:Jakarta
> Locality Name (eg, city) []:Jakarta
> Organization Name (eg, company) [Internet Widgits Pty
> Ltd]:ubuntu
> Organizational Unit Name (eg, section) []:ubuntu
> Common Name (eg, YOUR name) []:ubuntu.linux.vmw
> Email Address []:steve.van.christie at gmail.com
>
> 20. Edit Procmail
> sudo vim /etc/procmailrc
>
> DROPPRIVS=yes
> :0fw
> | /usr/bin/spamc
> :0
> * ^X-Spam-Status: Yes
> $HOME/spam
>
> 21. Backup and Edit Dovecot Configuration
> cp /etc/dovecot/dovecot.conf /home/sugizo/bkup/dovecot.conf.ori
> sudo vim /etc/dovecot/dovecot.conf
>
> protocols = imap imaps pop3 pop3s
> disable_plaintext_auth = no
> ssl_disable = no
> mail_debug = yes
> auth_debug = yes
> auth_debug_passwords = yes
>
> auth default {
> mechanisms = plain login
> passdb pam {
> }
> userdb passwd {
> }
> socket listen {
> client {
> path = /var/spool/postfix/private/auth
> mode = 0660
> user = postfix
> group = postfix
> }
> }
> }
>
> 22. Backup and Edit SASL Authentification Configuration
> cp /etc/default/saslauthd /home/sugizo/bkup/saslauthd.ori
> sudo vim /etc/default/saslauthd
>
> START=yes
>
> 23. Add Postfix User to SASL Group
> sudo adduser postfix sasl
> 24. Backup and Enable SquirrelMail on Apache Configuration
> cp /etc/apache2/apache2.conf /home/sugizo/bkup/apache2.conf.ori
> sudo vim /etc/apache2/apache2.conf
>
> Include /etc/squirrelmail/apache.conf
>
> 25. Create User Fetchmail
> sudo vim /home/sugizo/.fetchmailrc
>
> poll pop.gmail.com
> proto pop3
> port 995
> user "steve.van.christie"
> pass "*****"
> is sugizo
> fetchall
> ssl
> poll pop3.live.com
> proto pop3
> port 995
> user "steve_van_christie at hotmail.com"
> pass "*****"
> is sugizo
> fetchall
> ssl
> poll pop.mail.yahoo.com
> proto pop3
> port 110
> user "steve_van_christie"
> pass "*****"
> is sugizo
> fetchall
> poll pop.aol.com
> proto pop3
> port 110
> user "stevevanchristi at aol.com"
> pass "*****"
> is sugizo
> fetchall
> poll pop.mail.yahoo.co.jp
> proto pop3
> user "stevevanchristie"
> pass "*****"
> is sugizo
> fetchall
> poll pop.aol.com
> proto pop3
> user "sugizo at japan.com"
> pass "*****"
> is sugizo
> fetchall
> poll pop.icqmail.com
> proto pop3
> user "steve_van_christie at icqmail.com"
> pass "*****"
> is sugizo
> fetchall
> poll imap.mail.ovi.com
> proto imap
> port 993
> user "steve_van_christie at ovi.com"
> pass "*****"
> is sugizo
> fetchall
> ssl
> poll localhost
> proto pop3
> port 2000
> user "steve_van_christie at linuxmail.org"
> pass "*****"
> is sugizo
> fetchall
>
> 26. Backup and Edit PHP Configuration File
> cp /etc/php5/apache2/php.ini /home/sugizo/bkup/php.ini.ori
> sudo vim /etc/php5/apache2/php.ini
>
> memory_limit = 32M
> post_max_size = 32M
> upload_max_filesize = 32M
> extension=msql.so
>
> 27. Backup and Edit Apache Configuration
> cp /etc/apache2/apache2.conf /home/sugizo/bkup/apache2.conf.ori
> sudo vim /etc/apache2/apache2.conf
>
> ServerAdmin sugizo at japan.com
> ServerName ubuntu.linux.vmw
>
> 28. Restart Mail Service
> sudo service spamassassin restart
> sudo service amavis restart
> sudo service clamav-daemon restart
> sudo service clamav-freshclam restart
> sudo service postfix restart
> sudo service dovecot restart
> sudo service saslauthd restart
> sudo service freepops restart
> sudo service apache2 restart
> sudo service fetchmail restart
> 29. Update Clam Anti Virus
> sudo freshclam
> 30. Test Squirrelmail
> Open Your Browser Type : http://ubuntu/squirrelmail
> or http://192.168.44.3/squirrelmail
> 31. Test SMTP
> telnet localhost 25
>
> ehlo localhost
> quit
>
> 32. Test IMAP
> telnet localhost 143
>
> 0 logout
>
> 33. Test POP3
> telnet localhost 110
>
> quit
>
> 34. Test Amavis
> telnet localhost 10024
>
> ehlo localhost
> quit
>
How about this:
https://help.ubuntu.com/community/GmailPostfixFetchmail
Wade
--
Registered Linux User: #480675
Registered Linux Machine: #408606
Linux since June 2005
More information about the ubuntu-users
mailing list