forwarding local mail from homeserver with postfix to webmail

1.8k Views Asked by At

In context with the title i have the following setup:

  • I own a hostname, lets say: my_hostname.com
  • The A record of my_hostname.com points to my home ip using dynamic dns, lets say: 50.50.50.50
  • My home router forwards ports to my homeserver: 80 & 22
  • the MX records of my_hostame.com point to: my_personal_hash.pamx1.hotmail.com
  • Within this outlook account i have a subaccount: my_name@my_hostname.com

and this all works great, i can use my_hostname.com to ssh to my homeserver, use my own webinterface and receive mail on my_name@my_hostname.com on the servers from microsoft which always has one online.

But now the following: my homeserver generates local mail. This with the use of crontab and people trying to guess my sudo password (just people at my place so not such a big deal). This is all placed in var/mail/my_name and i'm trying to forward these mails to my_name@my_hostname.com with postfix. (i have also tried [email protected]) but it all fails to get my mail out.

I know that my mail is probably rejected because i use a home server to send mail but how do i get around this.

This is my /etc/postfix/main.cf file:

# See /usr/share/postfix/main.cf.dist for a commented, more complete version
# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname

smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

readme_directory = no

# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

myhostname = my_hostname.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = localhost
relayhost =
mynetworks = 127.0.0.0/8, 192.168.1.0/30
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = loopback-only
inet_protocols = all
default_transport = error
relay_transport = error

virtual_maps = hash:/etc/postfix/virtual, regexp:/etc/postfix/virtual-regexp

In virtual-regexp is a forward to one of both tried mail addresses. after sending a test mail with "mail send" to my_name@localhost, the /var/log/mail.info generates the folowing:

Jan  7 18:44:47 homeserver postfix/pickup[7729]: 707C111FDEA: uid=0 from=<root>
Jan  7 18:44:47 homeserver postfix/cleanup[7960]: 707C111FDEA: message-id=    <20140107174447.707C111FDEA@my_hostname.com>
Jan  7 18:44:47 homeserver postfix/qmgr[3769]: 707C111FDEA: from=    <[email protected]_hostname.com>, size=329, nrcpt=2 (queue active)
Jan  7 18:44:47 homeserver postfix/error[7962]: 707C111FDEA: to=    <my_name@my_hostname.com>, orig_to=<my_name@localhost>, relay=none, delay=0.06,     delays=0.04/0/0/0.02, dsn=5.0.0, status=bounced (my_hostname.com)
Jan  7 18:44:47 homeserver postfix/error[7962]: 707C111FDEA: to=   <my_name@my_hostname.com>, orig_to=<make>, relay=none, delay=0.07, delays=0.04/0/0/0.03, dsn=5.0.0, status=bounced (my_hostname.com)
Jan  7 18:44:47 homeserver postfix/cleanup[7960]: 805CB11FDF6: message-id=<20140107174447.805CB11FDF6@my_hostname.com>
Jan  7 18:44:47 homeserver postfix/bounce[7963]: 707C111FDEA: sender non-delivery  notification: 805CB11FDF6
Jan  7 18:44:47 homeserver postfix/qmgr[3769]: 805CB11FDF6: from=<>, size=2359, nrcpt=1 (queue active)
Jan  7 18:44:47 homeserver postfix/qmgr[3769]: 707C111FDEA: removed
Jan  7 18:44:47 homeserver postfix/error[7962]: 805CB11FDF6: to=<my_name@my_hostname.com>, orig_to=<[email protected]_hostname.com>, relay=none, delay=0.05, delays=0.03/0/0/0.02, dsn=5.0.0, status=bounced (my_hostname.com)
Jan  7 18:44:47 homeserver postfix/qmgr[3769]: 805CB11FDF6: removed

What major mistake am i making and how do i get my internal generated mail into my webmail?

1

There are 1 best solutions below

0
On

Ok, so with some research I found my answer.

To start, I made two mistakes. The first one was actually pretty obvious after looking everything over a few times. Just by removing:

default_transport = error
relay_transport = error

The first problem was solved but then i was left with:

Jan  8 10:13:55 homeserver postfix/smtp[12914]: B62C311FE09: to=<[email protected]>, orig_to=<my_name@localhost>, relay=none, delay=1588, delays=1438/0.01/150/0, dsn=4.4.1, status=deferred (connect to alt4.gmail-smtp-in.l.google.com[174.193.63.25]:25: Connection timed out)

when i was forwarding to my gmail account. Also forwarding to my_name@my_domain.com generated the connection time out.

After googling around, I found in this topic that my ISP might be blocking outgoing port 25 traffic. This can be verified using:

telnet aspmx.l.google.com 25

if it does not generate Connected to aspmx.l.google.com but a timeout after half a minute or so than your ISP is blocking your outgoing traffic. {don't forget installing telnet before using it ;) }.

And this was my second problem. Luckily I broke my neck less hard by solving this one.

By redirecting through a secure connection using port 587 I was able to send mail. To do this I used this post and a new google account for my server. I am not going to retype the whole post so just click it and read it if it finds your interest. I also removed the virtual-regexp file and linker to be compatible.

Now I send mail from my home server through [email protected] to my_name@my_hostname.com through port 587 and it all works great!

Jan  8 12:09:28 homeserver postfix/smtp[14135]: 6402811FE19: to=<my_name@my_hostname.com>, orig_to=<my_name@localhost>, relay=smtp.gmail.com[173.194.65.109]:587, delay=7063, delays=7061/0.04/0.58/1.4, dsn=2.0.0, status=sent (250 2.0.0 OK 1389179378 v7sm188296448eel.2 - gsmtp)