LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 10-30-2011, 02:04 PM   #1
Malaphus
LQ Newbie
 
Registered: Jul 2011
Location: Charlotte, NC
Distribution: Debian, BSD
Posts: 13

Rep: Reputation: Disabled
Postfix relaying through gmail with aliases


Hello all,

I have a server on my home network and I'd like to do the following:

- Forward all mail to gmail (working)
- Alias the various system accounts to a user that exists on my gmail domain

Currently I am using google apps with my own domain, so mail to me@mydomain.com goes to my gmail apps account, which I can check via http://mail.mydomain.com or via imap, pop, etc.

With my current postfix settings I can successfully send mail to "me@mydomain.com", or to just "me" and postfix happily relays the mail to smtp.gmail.com.

The problem is with my /etc/aliases, I currently have:

root: me

However mail to "root" gets relayed to root@mydomain.com instead of me@mydomain.com, and since root is not a valid account in my google apps domain, the me@mydomain.com user gets a bounceback sayins the root account does not exist.

Here is my postfix main.cf:

Code:
myhostname = myserver.mydomain.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = myserver.mydomain.com, localhost.mydomain.com, localhost
relayhost = [smtp.gmail.com]:587
mynetworks = 127.0.0.0/8 10.1.1.0/24
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = loopback-only

# TLS parameters
smtp_tls_CAfile = /etc/postfix/cacert.pem
smtp_tls_cert_file = /etc/postfix/mydomain-cert.pem
smtp_tls_key_file = /etc/postfix/mydomain-key.pem
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtp_use_tls = yes
smtpd_tls_CAfile = /etc/postfix/cacert.pem
smtpd_tls_cert_file = /etc/postfix/mydomain-cert.pem
smtpd_tls_key_file = /etc/postfix/mydomain-key.pem
smtpd_tls_received_header = yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_use_tls = yes

# SASL parameters
smtpd_sasl_auth_enable = no
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtpd_sasl_local_domain = $myhostname
smtp_sasl_security_options = noanonymous
smtp_sasl_tls_security_options = noanonymous
The contents of /etc/mailname are:
mydomain.com


When sending mail to root, the mail.log contains:

Code:
Oct 30 15:00:58 neon postfix/smtp[18939]: 37366340887: to=<root@mydomain.com>, orig_to=<root>, relay=smtp.gmail.com[74.125.47.108]:587, delay=2.3, delays=0.04/0.02/0.78/1.4, dsn=2.0.0, status=sent (250 2.0.0 OK 1320001277 o22sm20905675yhk.17)
As you can see, the mail is properly relayed to gmail however postfix is not honoring the /etc/aliases file, and sending the mail to root@mydomain.com instead of me@mydomain.com

If I fiddle with the myhostname, mydestinations, etc variables I can get postfix to honor the aliases file but then it stops relaying, and I see this instead:

Code:
Oct 30 14:38:50 neon postfix/local[18014]: 69DD0340887: to=<me@mydomain.com>, orig_to=<root>, relay=local, delay=0.06, delays=0.04/0.01/0/0.02, dsn=2.0.0, status=sent (delivered to command: procmail -a "$EXTENSION")
Which obviously is not what I want, because since the mail was delivered locally I never get it in my gmail account.

Can anyone explain the steps necessary to get relaying working properly while still honoring the aliases, so that I can send mail to "root" (or more likely cron, etc) and have it relay through gmail and arrive at me@mydomain.com's mailbox?

Thanks in advance!
 
Old 10-30-2011, 09:58 PM   #2
dman777
Member
 
Registered: Dec 2010
Distribution: Gentoo
Posts: 232

Rep: Reputation: 8
For what you want I would not use /etc/aliases. Instead, use /etc/postfix/virtual which can act as a drop in replacement to /etc/aliases. The only benifit is with /etc/aliases you can run commands in that file. However, I don't ever see a need to...so bob's yer uncle.
 
Old 09-01-2012, 07:01 PM   #3
fory@trihard.net
LQ Newbie
 
Registered: Sep 2012
Posts: 1

Rep: Reputation: Disabled
I'm having the exact problem. How did you fix?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Postfix Gmail and relaying Ammad Linux - Server 1 07-14-2009 01:49 PM
sendmail - can't send to gmail/hotmail... - Relaying denied. IP name possibly forged spids Linux - Server 2 03-30-2009 07:57 PM
Postfix relaying problem tsyuoi Linux - Server 3 10-18-2007 01:15 PM
Postfix Relaying trueguy2001_in Linux - Security 1 02-22-2006 02:03 PM
Postfix and relaying, help! Sizam Linux - Software 1 04-11-2005 04:37 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 01:19 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration