0

I have an ubuntu 16.04 web server with a forwarded mx record. On server, I installed sendmail. I have multiple vhosts runnning. One of them is "xxx-tele.com".

Now I want to setup sendmail that all mails sent to info@xxx-tele.com should be forwarded to xxx@tele.com which is a mailbox on a different mail server inside of my network.

First I added a /etc/mail/virtusertable with

info@xxx-tele.com        xxx@tele.com

and with "makemap hash virtusertable.db < virtusertable" I created the hash file. In /etc/mail/sendmail.mc I added the line

FEATURE(`virtusertable', `hash -o /etc/mail/virtusertable.db')dnl

and I run the

m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf

command and restarted sendmail with "service sendmail reload".

Now, I try command

sendmail -bv info@xxx-tele.com

and I just get response: info@xxx-tele.com... User unknown

The xxx-tele.com is appended in /etc/hosts and in /etc/mail/local-host-names

How can I setup sendmail to just forward this address and refuse all other?

The command: echo '$=w' | sendmail -bt just returns:

ADDRESS TEST MODE (ruleset 3 NOT automatically invoked) 
Enter <ruleset> <address> 
> localhost.tele.com
web
xxx-tele.com
[internal.dmz.ip4.address]
localhost
web.tele.com
[127.0.0.1]
web.tele.com
[localhost.tele.com]

Best, dwi

here are the provided information: The answer for 1.) is

ADDRESS TEST MODE (ruleset 3 NOT automatically invoked) 
Enter <ruleset> <address>
 > map_lookup: virtuser (info@xxx-tele.com) returns myuser@tele.com (0) 

The answer for 2.) is

ADDRESS TEST MODE (ruleset 3 NOT automatically invoked)
Enter <ruleset> <address>
> canonify input: info @ xxx-tele.com
Canonify2 input: info < @ xxx-tele.com >
map_lookup(host, xxx-tele.com, %0=xxx-tele.com) => localhost.xxx.com. (0)
Canonify2 returns: info < @ localhost.xxx.com . >
canonify returns: info < @ localhost.xxx.com . >
parse input: info < @ localhost.xxx.com . >
Parse0 input: info < @ localhost.xxx. com . >
map_lookup(dequote, info, %0=info) => NOT FOUND (0)
Parse0 returns: info < @ localhost.xxx.com . >
Parse1 input: info < @ localhost. xxx.com . >
map_lookup(virtuser, info@localhost.xxx.com, %0=info@localhost.xxx.com, %1=info) => NOT FOUND (0)
map_lookup(virtuser, @localhost.xxx.com, %0=@localhost.xxx.com, %1=info) => NOT FOUND (0)
Parse1 returns: $# local $: info
parse returns: $# local $: info

The third response is:

> root@web:~# _res.options = 812c3, HasWildcardMX = 0
Enter <ruleset> <address>
> canonify           input: info @ xxx-tele . com
Canonify2          input: info < @ xxx-tele . com >
Canonify2        returns: info < @ localhost . xxx. com . >
canonify         returns: info < @ localhost . xxx. com . >
parse              input: info < @ localhost . xxx. com . >
Parse0             input: info < @ localhost . xxx. com . >
Parse0           returns: info < @ localhost . xxx. com . >
Parse1             input: info < @ localhost . xxx. com . >
Parse1           returns: $# local $: info
parse            returns: $# local $: info

My host file is like:

127.0.0.1       localhost    localhost.xxx.com    xxx-tele.com
local.dmz.ip4.address      web.xxx.com     web    xxx-tele.com
1

Domain gets rewritten by host map lookup before virtusertable lookup
as indicated by debug output provided by

echo '3,0 info@xxx-tele.com' | sendmail -d60.5 -bt

Changing your /etc/hosts entry should fix it

### Old Entry
# 127.0.0.1       localhost    localhost.xxx.com    xxx-tele.com
### New Entry
127.0.0.1       localhost  xxx-tele.com
1

Sendmail: debugging virtusertable

1) Check if sendmailcan access the entry in virtusetable

As root execute:

echo /map virtuser info@xxx-tele.com  | sendmail -bt

2) Check if sendmail conducts virtusertable lookups for the email.
As root execute:

echo '3,0 info@xxx-tele.com' | sendmail -d60.5 -bt

-d60.5 traces (all) maps lookups including virtusertable lookups

3) If the domain is rewritten by host map lookup before virtusertable lookups then check DNS lookups and post /etc/hots entries with xxx-tele.com

echo '3,0 info@xxx-tele.com' | sendmail -d8.20 -bt
  • The answer for 1.) is ADDRESS TEST MODE (ruleset 3 NOT automatically invoked) Enter <ruleset> <address> > map_lookup: virtuser (info@xxx-tele.com) returns myuser@tele.com (0) – Wyphorn Jul 4 '17 at 8:38
  • The answer for second command is: ADDRESS TEST MODE (ruleset 3 NOT automatically invoked) Enter <ruleset> <address> > canonify input: info @ xxx-tele.com Canonify2 input: info < @ xxx-tele.com > map_lookup(host, xxx-tele.com, %0=xxx-tele.com) => localhost.xxx.com. (0) Canonify2 returns: info < @ localhost.xxx.com . > canonify returns: info < @ localhost.xxx.com . > parse input: info < @ localhost.xxx.com . > Parse0 input: info < @ localhost.xxx. com . > map_lookup(dequote, info, %0=info) => NOT FOUND (0) Parse0 returns: info < @ localhost.xxx.com . > – Wyphorn Jul 4 '17 at 8:40
  • rest of trace: Parse1 input: info < @ localhost. xxx.com . > map_lookup(virtuser, info@localhost.xxx.com, %0=info@localhost.xxx.com, %1=info) => NOT FOUND (0) map_lookup(virtuser, @localhost.xxx.com, %0=@localhost.xxx.com, %1=info) => NOT FOUND (0) Parse1 returns: $# local $: info parse returns: $# local $: info – Wyphorn Jul 4 '17 at 8:40
  • I have extended the answer. [I should include extra info provided to your question later today] – AnFi Jul 4 '17 at 11:55
  • Thanks so far, I edited my comment with new information. – Wyphorn Jul 4 '17 at 14:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.