Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Sun Feb 27, 2005 5:03 pm 
Offline
Senior Newbie

Joined: Tue Feb 22, 2005 12:17 am
Posts: 17
Location: Montreal, QC
Hi everyone,

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 me@mydomain.net is redirected to info@somethingelse.com and so on for a couple of email addresses. The destination email will take care of the rest (spam filtering, POP access, and so on).
  • 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:
    Code:
    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!


Top
   
 Post subject:
PostPosted: Sun Feb 27, 2005 5:12 pm 
Offline
Senior Member
User avatar

Joined: Sun Feb 08, 2004 7:18 pm
Posts: 562
Location: Austin
I really like Exim4, and as it's the default in Sarge anyway I recommend you stick with it.

I've set up pretty much exactly what you're talking about. In /etc/exim4/conf.d/router, I created a file called 160_local_virtual_users containing:

Code:
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:

Code:
*: 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.


Top
   
 Post subject:
PostPosted: Sun Feb 27, 2005 5:16 pm 
Offline
Senior Member
User avatar

Joined: Sun Feb 08, 2004 7:18 pm
Posts: 562
Location: Austin
Oh, and as far as handling specific addresses, in /etc/aliases-domain/mydomain.com :

Code:
user1:    user1@otherplace.com
user2:    user2@otherplace.com
bad1:     :blackhole:
*:        catchall@otherplace.com


Top
   
 Post subject:
PostPosted: Sun Feb 27, 2005 5:19 pm 
Offline
Senior Member
User avatar

Joined: Sun Feb 08, 2004 7:18 pm
Posts: 562
Location: Austin
Should have read all your questions before starting this... :-)

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.


Top
   
 Post subject: Wow!
PostPosted: Sun Feb 27, 2005 5:21 pm 
Offline
Senior Newbie

Joined: Tue Feb 22, 2005 12:17 am
Posts: 17
Location: Montreal, QC
Wow thanks Xan for all the answers and the speed! I'm trying this out this evening and I'll give some news about the results. :)


Top
   
 Post subject: Configuration
PostPosted: Sun Feb 27, 2005 7:17 pm 
Offline
Senior Newbie

Joined: Tue Feb 22, 2005 12:17 am
Posts: 17
Location: Montreal, QC
Is there something else to do? It doesn't work.

Here's what I did to configure the whole thing.

  1. I've installed exim4, for some reason, I still had exim3.
  2. I've added the 160_local_virtual_users in /etc/exim4/conf.d/router.
  3. I've added the mydomain.com file (yes, with my own domain ;)) in the /etc/aliases-domains.
  4. Is there another line to add to the main configuration?

Here's what I did for debugging:

  1. I've sent emails to a valid user: nothing. No mail-delivery error, no forward.
  2. I've sent emails to an invalid user: one of them returned a mail-delivery error after a *long* wait.
  3. 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.
  4. 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:

Quote:
* put this into /etc/exim4/conf.d/router/160_local_virtual_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!


Top
   
 Post subject: Update
PostPosted: Sun Feb 27, 2005 9:03 pm 
Offline
Senior Newbie

Joined: Tue Feb 22, 2005 12:17 am
Posts: 17
Location: Montreal, QC
Ok, I did receive the emails in my Linux account (when I type mail) so they are not forwarded to my other@domain.net. I guess there's a problem with my config. Any clue to why it is not working?


Top
   
 Post subject:
PostPosted: Sun Feb 27, 2005 11:28 pm 
Offline
Senior Member
User avatar

Joined: Sun Feb 08, 2004 7:18 pm
Posts: 562
Location: Austin
hmm...

Did you run update-exim4.conf and restart Exim after making config file changes? That's what makes Exim 4 assimilate changes.


Top
   
 Post subject: Not yet...
PostPosted: Mon Feb 28, 2005 12:00 am 
Offline
Senior Newbie

Joined: Tue Feb 22, 2005 12:17 am
Posts: 17
Location: Montreal, QC
I can now receive mail but only if:
  • The mail is forwarded to a completely different domain (I have mydomain.net (my linode) and mydomain.com (another)). When I want user@mydomain.net to be redirected to mydomain.com, I receive it in my linux account instead of on mydomain.com. Weird.
  • On my system, I have the account user1 created. I've made 2 aliases, user1@mydomain.net and admin@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:


Top
   
 Post subject:
PostPosted: Mon Feb 28, 2005 12:22 am 
Offline
Senior Member
User avatar

Joined: Sun Feb 08, 2004 7:18 pm
Posts: 562
Location: Austin
You say you've made two aliases: user1@mydomain.net and admin@mydomain.net. Just to double-check: inside the file /etc/aliases-domains/mydomain.net, they're just known as user1 and admin. So it should look like:
Code:
user1:    someplace@else.net
admin:    somewhere@else.net


Is that what you have?


Top
   
 Post subject: Something like that...
PostPosted: Mon Feb 28, 2005 12:37 am 
Offline
Senior Newbie

Joined: Tue Feb 22, 2005 12:17 am
Posts: 17
Location: Montreal, QC
I exactly have in /etc/aliases-domains/mydomain.net:
Code:
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?


Top
   
 Post subject:
PostPosted: Mon Feb 28, 2005 12:53 am 
Offline
Senior Member
User avatar

Joined: Sun Feb 08, 2004 7:18 pm
Posts: 562
Location: Austin
I just tried exactly that alias file, and it worked exactly as expected. I went through all the Exim config files to find the ones that I'd modified, and the only one that would remotely relate to what we're doing was 400_exim4-config_system_aliases. I'm not sure what I even changed, or if it relates, but it now reads:

Code:
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...


Top
   
 Post subject:
PostPosted: Mon Feb 28, 2005 2:06 am 
Offline
Senior Newbie

Joined: Tue Feb 22, 2005 12:17 am
Posts: 17
Location: Montreal, QC
I've got the same thing in 400_exim4-config_system_aliases, seems to be the default configuration. And normally, if I read correctly, the email shouln't reach this file, it should be routed with our 160_ file.

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! :)


Top
   
 Post subject:
PostPosted: Mon Feb 28, 2005 2:18 am 
Offline
Senior Member
User avatar

Joined: Sun Feb 08, 2004 7:18 pm
Posts: 562
Location: Austin
Sorry it didn't go more smoothly... It's probably something stupid we're both overlooking.

If I think of it at 4 in the morning I'll post here. :-) And if you need to know anything more about my config, let me know.


Top
   
 Post subject:
PostPosted: Thu Apr 05, 2007 12:41 am 
Offline
Senior Newbie

Joined: Thu Mar 29, 2007 12:16 pm
Posts: 9
Location: burlington, nc
i'm probably not going to be of too much help here, but i would like to say i just used the above mentioned virtual_users router and it worked just fine for me. and to say thanks so much for that bit of info.

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:
Quote:
temporarily rejected RCPT user@the.domain : failed to open /etc/aliases-domains/the.domain for linear search: No such file or directory


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.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group