0

How can I send mail to a local user with a domain prefixed username?

Running SUSE Linux Enterprise Server 11.3 joined to an active directory domain with Heirloom mailx version 12.5 7/5/10

Scenario:

I have 2 users on the server, one local user account and one domain user account:

  • jeff
  • DOM1\john

Logged in as DOM1\john, I can issue this command from terminal echo "hello" | mail -s "test" jeff and jeff successfully receives the message. Not surprisingly, the header reads an escaped backslash in the FROM field From: "DOM1\\john"@server.example.com

Oddly, if jeff simply replies to the message, jeff will get an Undelivered Mail Returned to Sender in inbox. The header says To: DOM1john@server.example.com, so I can see that the backslash is getting stripped out. I have tried the following commands as jeff to attempt to escape the backslash, all to no avail, and the backslash is always omitted in the TO header of the undelivered message:

  • echo "hello" | mail -s "test" DOM1\john
  • echo "hello" | mail -s "test" 'DOM1\john'
  • echo "hello" | mail -s "test" "DOM1\john"
  • echo "hello" | mail -s "test" DOM1\john@server.example.com
  • echo "hello" | mail -s "test" 'DOM1\john'@server.example.com
  • echo "hello" | mail -s "test" "DOM1\john"@server.example.com
  • echo "hello" | mail -s "test" DOM1\\john
  • echo "hello" | mail -s "test" 'DOM1\\john'
  • echo "hello" | mail -s "test" "DOM1\\john"
  • echo "hello" | mail -s "test" DOM1\\john@server.example.com
  • echo "hello" | mail -s "test" 'DOM1\\john'@server.example.com
  • echo "hello" | mail -s "test" "DOM1\\john"@server.example.com

Stranger still, if I try 3 backslashes, echo "hello" | mail -s "test" DOM1\\\john, it doesn't deliver the message nor issue an undelivered message, it just fails silently.

And if I try to just send the mail without the domain prefix, echo "hello" | mail -s "test" john, I get the expected undelivered message saying that user john doesn't exist.

Also, to be clear, yes these domain users have email accounts like john@dom1.example.com, but we don't want to send to that mail server account - we just want to use the local mail accounts on SLES so they can communicate with the other local non-domain accounts on that server.

0

You gave in too easily. You saw the header

From: "DOM1\\john"@server.example.com

and that is what you need, but you must preserve the double-quotes and double backslash:

echo "hello" | mail -s "test" '"DOM1\\john"@server.example.com'

From wikipedia on the local part of an email address:

Space and "(),:;<>@[\] characters are allowed with restrictions (they are only allowed inside a quoted string, ... and in addition, a backslash ... must be preceded by a backslash).

A quoted string may exist ... when the outermost quotes are the outermost characters of the local-part ... e.g. "abcdefghixyz"@example.com. Quoted strings and characters however, are not commonly used. RFC 5321 also warns that "a host that expects to receive mail SHOULD avoid defining mailboxes where the Local-part requires (or uses) the Quoted-string form".

  • I was so hopeful, but this one doesn't work either. It strips it out also... – Jeff Puckett Apr 6 '16 at 16:23
  • Perhaps it is the mail command which is at fault. Try using sendmail directly: echo "hello" | sendmail -v '"DOM1\\john"@server.example.com' – meuh Apr 6 '16 at 16:51
  • so that command spits out Mail Delivery Status Report will be mailed to <jeff>. and then when I look at the message, it says <"DOM1\\john"@server.example.com>: delivery via local: delivered to mailbox however, when I login as DOM1\john, and run mail I get No mail for DOM1\john so it says it's sent, but never received... – Jeff Puckett Apr 6 '16 at 17:44
  • Try looking at root's mailbox or /var/spool/mail/ for any failure mails. If you are really using sendmail you could possibly setup /etc/aliases (or /etc/mail/aliases) for each id, and its version without backslash, to the right spool file so that they have a version of their id that will work. – meuh Apr 6 '16 at 18:03

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.