Sendmail, Virtual hosts, Apache

Hi,

A mail sent from myaccount@yahoo.com to mail@myvirtualdomain.org bounces.

tail -f /var/mail/maillog
Code:
May 11 10:26:42 web sm-mta[27492]: r4BEQg40027492: ruleset=check_rcpt, arg1=<mail@myvirtualdomain.org>, relay=nm25.bullet.mail.bf1.yahoo.com [98.139.212.184], reject=550 5.7.1 <mail@myvirtualdomain.org>... Relaying denied
May 11 10:26:42 web sm-mta[27492]: r4BEQg40027492: from=<myaccount@yahoo.com>, size=0, class=0, nrcpts=0, proto=ESMTP, daemon=IPv4, relay=nm25.bullet.mail.bf1.yahoo.com [98.139.212.184]

Sendmail works fine for my primary domain (myprimarydomain.org). I can send and receive emails from internal and external hosts for this. It's the virtual domain that bounces.

Logged in as root - I've created user 'mail' on myprimarydomain.org.

My MX record entry for myvirtual domain:
Code:
 	Name 			Content 			Preference 	TTL
	myvirtualdomain.org 	mail.myvirtualdomain.org 	10 		3600

and my Apache virtual host configuration:

/usr/local/etc/apache22/extra/httpd-vhosts.conf
Code:
<VirtualHost *:80>
    ServerAdmin webmaster@myprimarydomain.org
    DocumentRoot "/var/www/myprimarydomain"
    ServerName myprimarydomain.org
    ServerAlias www.myprimarydomain.org
    ErrorLog "/var/log/myprimarydomain.org-error_log"
    CustomLog "/var/log/myprimarydomain.org-access_log" common
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin andy@myvirtualdomain.org
    DocumentRoot "/var/www/myvirtualdomain"
    ServerName myvirtualdomain.org
    ServerAlias www.myvirtualdomain.org
    ErrorLog "/var/log/myvirtualdomain.org-error_log"
    CustomLog "/var/log/myvirtualdomain.org-access_log" common
</VirtualHost>

Is there a quick fix, i.e. which file(s) do I edit?

Are any of these the likely candidates?
/etc/mail/local-host-names
/etc/mail/aliases
/etc/mail/access

If so, can you provide an example? It would really help before I have to wade through loads of stuff sometimes unrelated to get to an answer.
 
I have no idea why Apache's configuration would have any bearing on an email problem. Only DNS or your Sendmail configuration may cause problems. It seems to me that your local-host-names and your virtusertable need to be set up properly. Post them.
 
DutchDaemon said:
I have no idea why Apache's configuration would have any bearing on an email problem. Only DNS or your Sendmail configuration may cause problems. It seems to me that your local-host-names and your virtusertable need to be set up properly. Post them.

Massive clue DutchDaemon, thankyou.

/etc/mail/local-host-names
Code:
myvirtualdomain.org 
mail.myvirtualdomain.org
and /etc/mail/virtusertable
Code:
# $FreeBSD: release/9.0.0/etc/mail/virtusertable.sample 68266 2000-11-02 23:32:31Z dirk $
#
# Map one or all usernames at a source hostname to a specific (or the same)
# username at another target hostname.  Remember to add the source hostname
# to /etc/mail/local-host-names so that sendmail will accept mail for the
# source hostname.
#
#username@a.sample.hostname	localuser
#username@a.sample.hostname	specificuser@a.possibly.different.hostname

mail@myvirtualdomain.org		mail

Don't forget to:
cd /etc/mail
make restart
and I can define several (or more) virtual hosts with corresponding emails. Email now works.
 
Ok. Do note that you now have only one valid email address under myvirtualdomain.org. All other addresses (other than mail@) will be rejected.
 
DutchDaemon said:
Ok. Do note that you now have only one valid email address under myvirtualdomain.org. All other addresses (other than mail@) will be rejected.

OK. Is there a workaround for this? Can I define something more generic that would catch all mappings?

/etc/mail/virtusertable
Code:
@myvirtualdomain.org		mail, fred, john

/etc/mail/local-host-names
Code:
myvirtualdomain.org 
mail.myvirtualdomain.org
fred.myvirtualdomain.org
john.myvirtualdomain.org

Untested.
 
You can use a catch-all rule for the default domain (so every address under the domain will be accepted) plus mappings for specific addresses:

Code:
@myvirtualdomain.org        mike
joe@myvirtualdomain.org     joe
pete@myvirtualdomain.org    pete
sam@myvirtualdomain.org     sam

or you can choose to have only the specific addresses, rejecting all non-existent addresses:

Code:
[email]joe@myvirtualdomain.org[/email]     joe
[email]pete@myvirtualdomain.org[/email]    pete
[email]sam@myvirtualdomain.org[/email]     sam

So email to carl@myvirtualdomain.org will be refused with a 'user unknown'.

Note that if you want email to go to more than one local mailbox, you will have to use an alias:

Code:
@myvirtualdomain.org        alias-name

In /etc/mail/aliases:
Code:
alias-name:   mike, joe, someone@domain.test

You cannot define more than one RHS entry in virtusertable.
 
DutchDaemon said:
Note that if you want email to go to more than one local mailbox, you will have to use an alias:

Excellent explanation, thank you. It appears that mail is now mapped correctly for virtual domains on my system.
 
Back
Top