What do I need to forward, and only forward?
I'm running Debian Sarge and I want to create aliases for the emails sent @mydomain.net. I'm new to the mail server thing and I don't know where to start. What I know is:
* I don't want to have a POP server on my Linode, I just want that, for example, the mail sent to
The email addresses I want to forward from my Linode to somewhere else are not necessarily Linux accounts.
I don't want my box to be insecure and allow anybody to use it to relay spam everywhere.
I know I have to set my MX record correctly to point on my Linode (I think I'm done here).
No problem installing postfix if that's what I need (I heard it's safer than sendmail and even exim).
I've got mySQL so I could use something like postfix-mysql is needed.
I'm behind a firewall with only the minimum ports opened (of course!) and I'm not sure what's supposed to be opened for relaying the mail to my Linode.
I'd like to send to a "blackhole" every mail for which I didn't specify a redirection (forward). I want something like:
user1@mydomain.net -> user1@whatever.com user2@mydomain.net -> user2@whatever.com info@mydomain.net -> user1@whatever.com other -> :blackhole: (or /dev/null)
So, could someone help me out, at least to give me a hint of what kind of setup I should try?
Thanks!
14 Replies
I've set up pretty much exactly what you're talking about. In /etc/exim4/conf.d/router, I created a file called 160localvirtual_users containing:
virtual_users:
debug_print = "R: virtual_users for $local_part@$domain"
driver = redirect
domains = +local_domains
allow_fail
allow_defer
data = ${lookup{$local_part}lsearch*@{/etc/aliases-domains/$domain}}
qualify_preserve_domain
no_more
Suppose your domain is mydomain.com. All you have to do now is create a file /etc/aliases-domains/mydomain.com containing:
*: myreal@address.com
That'll send all mail coming in to that domain (assuming you've already told exim you'll accept mail for that domain) to your other address.
user1: user1@otherplace.com
user2: user2@otherplace.com
bad1: :blackhole:
*: catchall@otherplace.com
In order to receive mail from the outside, your Linode will need to be able to accept new connections on port 25. When it forwards mail someplace else, it will connect to the other machine's port 25.
So your firewall rules must allow unsolicited inbound connections on port 25, and new connections to be created outgoing to port 25.
Here's what I did to configure the whole thing.
4. I've installed exim4, for some reason, I still had exim3.
I've added the 160localvirtual_users in /etc/exim4/conf.d/router.
I've added the mydomain.com file (yes, with my own domain
;) ) in the /etc/aliases-domains.Is there another line to add to the main configuration?
Here's what I did for debugging:
4. I've sent emails to a valid user: nothing. No mail-delivery error, no forward.
I've sent emails to an invalid user: one of them returned a mail-delivery error after a long wait.
I've connected with "telnet mail.mydomain.com 25" to test the exim4 server. I can send a mail (all the answers are correct) but I didn't received it.
I've tried sending to another domain than my own and I have a message telling me I can't relay to this domain, good!
So, it seems my firewall is setup correctly, that the exim4 server is running and can receive email to relay but that it disapears in it. Maybe it is not relayed or maybe it doesn't know where to relay it (bad configuration?).
I've found a message telling me to add a line in the main configuration but I'm not sure to understand:
> * put this into /etc/exim4/conf.d/router/160localvirtual_users
- add a "domainlist virtual_domains = …" to conf.d/main/
I feel a bit lost, I'm not sure what I should do next to pinpoint my problem. Any clues?
Thanks again for your time!
Did you run update-exim4.conf and restart Exim after making config file changes? That's what makes Exim 4 assimilate changes.
* The mail is forwarded to a completely different domain (I have mydomain.net (my linode) and mydomain.com (another)). When I want
- On my system, I have the account user1 created. I've made 2 aliases,
user1@mydomain.net andadmin@mydomain.net . So admin does not match any account and when I try this email, I've got a "account does not exist" return mail.
Also, altought I did an update-exim4.conf and restarted exim, the aliases are not refreshed every time. I'm not sure to understand.:roll:
user1: someplace@else.net
admin: somewhere@else.net
Is that what you have?
user1: user1@elsewhere.com
admin: user1
*: :blackhole:
mydomain.net being my linode.
elsewhere.com is another domain.
user1 being an account on my linode.
admin is not an account.
Is that okay?
system_aliases:
debug_print = "R: system_aliases for $local_part@$domain"
driver = redirect
domains = +local_domains
allow_fail
allow_defer
data = ${lookup{$local_part}lsearch{/etc/aliases}}
# user = list
# group = mail
file_transport = address_file
# pipe_transport = address_pipe
# directory_transport = address_directory
Other than that, I'm not sure what to tell you…
I'll try to find something else, I'll post it here if I'm successful.
Thanks a lot for your time Xan. It was really helpful!
If I think of it at 4 in the morning I'll post here.
since i wanted some mail to fall through and be delivered locally, i removed the no_more line at the end.
one thing i found out is that you must have a domain alias file for each delivered domain or exim gives an error and won't accept recipient for that domain:
> temporarily rejected RCPT
one question for lpfavreau, when you configured exim4 the first time (or via dpkg-reconfigure exim4-config) did you select "Yes" for "Split configuration into small files?" if you selected No, then you would need to add Xan's bit of code somewhere inside exim4.conf.template. i had originally specified No, but later changed it to Yes with the dpkg-reconfigure command.