Problems with Mail Forwarding to aliases, relaying

18 posts / 0 new
Last post
#1 Tue, 05/26/2009 - 16:40
Dirk

Problems with Mail Forwarding to aliases, relaying

Hi, yesterday my provider complained about a wrongly set bounce address, so he received a lot of bounced email, due to my hit quota limit for the webspace...

At the same time he had the concern, my smtp server would be an open relay, which is why I set it more restrictive. However, I think I found the error at a different place, with some wrongly set aliases.

Now, I probably set either the limits to strict, or I really left my stmp server wide open...

This is what I want to do: - I have several virtual servers running, - for each virtual server I define an catchall adress which works as alias for an external email account on gmail, - email should arrive and directly go to where the virtual server specifies,

I read a lot in the past hours... Is this doable with virtualmin, or did it work before due to an openrelay smtp set up by mistake by me?

Tue, 05/26/2009 - 16:56
andreychek

Well, it's not an open relay to have a catch-all that forwards all email to an account at another site.

That's not an open relay, that's forwarding email :-)

Of course, catch-alls will collect a lot of spam; in my opinion, catch-alls pull in so much spam that they are not worthwhile.

But that's much different than being an open relay -- which allow non-authenticated remote users to relay email through your server to any account on the Net.

So you can do that in Virtualmin, it's not hard to setup, and it's not being an open relay to do so. In fact, once you have it setup and working, go to Google and search for "open relay test". There's a number of services that will verify that you aren't an open relay.

To setup what you want, just go into Edit Email Aliases, select "Add an alias to this domain", choose the "All Mailboxes" radio button, and choose "Forward to other address".

That should be all you need!
-Eric

Tue, 05/26/2009 - 17:01 (Reply to #2)
Dirk

Mhmmm, as it was setup before... thanks for the confirmation, that it should work.

In my fear of becoming banned by my provider, I probably messed something up with the standard settings, as Postfix didn't want to accept / relay / forward any mail and directly to the external address...

Is there any place, where I can look up default settings, as from a fresh installed system?

P.S.: Catchall is definitely not the best, but my lowpowered vServer should not deal with spam fighting, I let gmail do it...

Tue, 05/26/2009 - 17:07 (Reply to #3)
andreychek

Hmm, I'm not sure what you're after in regards to settings, or default settings.

Though, the answer is that there probably isn't a way to see how things look when your system was first installed unless you happened to keep backups from way back then :-)

You can see what the Virtualmin installer sets, by looking at the settings it adds in the Postfix config:

http://software.virtualmin.com/lib/mail-setup.pl

Regarding a catch-all not being the best -- an alternate way of doing that, rather than using a catch-all, would be to create the aliases that you need, and forward them individually over to your other email account.

Have a good one,
-Eric

Wed, 05/27/2009 - 08:38 (Reply to #4)
Dirk

Very nice solution, very last question...

The error only became apparent, because when emails bounced because of wrong set alias, they then went to postmaster@VHOSTVENDOR.TLD automatically, instead of postmaster@MYID.VHOSTVENDOR.TLD

At which place would I need to make a clear statement, to prevent my system to assume the first one would be right?

Sat, 05/30/2009 - 07:38 (Reply to #5)
Dirk

mhm, some Virtualmin cronjob still sends mail to my email adresses @VHOSTVENDOR.TLD ...

At which places could it be set wrong?

Sat, 05/30/2009 - 16:25 (Reply to #6)
Joe
Joe's picture

That depends. cronjob run reports send to root at the hostname of your box. It has nothing to do with Virtualmin (yes, Virtualmin creates cronjobs, but it doesn't have any magical configuration about where it mails reports to).

There are also some tasks that Virtualmin can setup to run from cron which can optionally be configured to send to other email addresses you specify. You haven't told us what specific cronjobs you're talking about, so I can't say which one you would need to change (if any).

For cronjob reports:

If the hostname of your box is correct (when you type "hostname" it returns the name you expect), then you probably just need to restart the cron daemon.

/etc/init.d/crond restart

--

Check out the forum guidelines!

Sat, 05/30/2009 - 12:35 (Reply to #7)
Dirk

More details... the emails goes to postmaster@VHOSTVENDOR.TLD. The postfix configuration set the bounce_notice_recipient and 2bounce_notice_recipient to postmaster (default), but which service adds @VHOSTVENDOR.TLD ?

Mon, 06/01/2009 - 13:55 (Reply to #8)
Dirk

Found the reason:
/etc/postfix/main.cf didn't contain explicit statements for mydomain and myhostname ... and the defaults pointed to VHOSTVENDOR.TLD.
Where is this loaded from?

Its now fixed, through adding it.

Mon, 06/01/2009 - 14:27 (Reply to #9)
Joe
Joe's picture

Depends on your OS. On Ubuntu it's in /etc/mailname (which is stupid, IMHO, but I didn't get a vote). On most systems it comes straight from the /etc/hosts file.

--

Check out the forum guidelines!

Tue, 05/26/2009 - 23:39
Dirk

Thanks for help... one more question.

I think I set all aliases correctly now in virtualmin for each server.
Still /etc/postfix/virtual contains additional entries, where I don't know where they come from.

Will this file be compiled by Virtualmin? If so from which ressources? Could I manually update /etc/postfix/virtual and it won't be overwritten by any other process?

Wed, 05/27/2009 - 00:19 (Reply to #11)
Joe
Joe's picture

virtual is the editable form. So, yes, you can edit it yourself outside of Virtualmin without fear of reprisals (generally). When you do, run this to generate the actual map db:

postmap hash:/etc/postfix/virtual

--

Check out the forum guidelines!

Wed, 05/27/2009 - 02:59
Dirk

<div class='quote'>postmap hash:/etc/postfix/virtual</div>

is this the same action like the command:
newaliases ?

Wed, 05/27/2009 - 04:46 (Reply to #13)
andreychek

It accomplishes a similar task, but newaliases updates only the /etc/aliases file.

You could always create a Bash alias called, say, &quot;newvirtual&quot; by typing this on the command line:

alias newvirtual=&quot;postmap hash:/etc/postfix/virtual&quot;

Now running &quot;newvirtual&quot; will execute the above postmap command.

And if you add that to your .bashrc file, it'll be run each time you log in.
-Eric

Tue, 06/02/2009 - 00:47
Dirk

Okay, I checked it - its Debian and I found the reference in both places to: MYID.VHOSTVENDOR.TLD

However, as I understand mydomain will be defaulted to the hostname above minus the subdomain, if not set. In a virtual host environment on a virtual providers machine at a providers network, this causes the described problem. Because I don't own the toplevel domain, is defaults bounces etc. to the providers postmaster instead of mine...

Maybe this could be somehow mentioned while installation? Or mydomain should be set automatically correctly in postfix?

Or is it just me :-P

Tue, 06/02/2009 - 01:47 (Reply to #15)
Joe
Joe's picture

<div class='quote'>Or is it just me</div>

It's just you. ;-)

Your hostname needs to be set correctly to a fully qualified, resolving, domain name. That's it. Don't agonize over it. Just fix your system hostname. If Postfix is saying it is your hosting provider, than your hostname is not set correctly.

What do you get when you run:

hostname

And:

hostname -f

--

Check out the forum guidelines!

Tue, 06/02/2009 - 03:04
Dirk

The hostname command shows my correct virtual server: MYID.VHOSTVENDOR.TLD

But, Virtualmin default settings in Module Postfix - Address Rewriting and Masquerading says:
Rewrite &quot;user&quot; to &quot;user@$mydomain&quot; X Yes No

Accordingly to http://www.postfix.org/postconf.5.html $mydomain is defined with $hostname minus subdomain.

$mydomain was not specified in /etc/postfix/main.cf and when checking it with postconf -d it would default to VHOSTVENDOR.TLD.

Although hostname is set correctly in the places you mentioned.

I did a workaround and specified $mydomain directly manual in /etc/postfix/main.cf

Tue, 09/15/2009 - 18:45
kenlyle

I think that I had at least one of the same issues as Dirk. My hosting comany wrote:

"

mydestination = localhost.$mydomain, localhost, mydomain.tld

I added mydomain.tld...

"

Where mydomain.tld is the same as the answer from the hostname command.

This seemed to be a key step in enabling my VSes to receive mail.

Thanks, K

Topic locked