LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   sendmail - Sending emails from the machine with name of the HOSTNAME (https://www.linuxquestions.org/questions/linux-server-73/sendmail-sending-emails-from-the-machine-with-name-of-the-hostname-934601/)

Oz. 03-15-2012 09:40 AM

sendmail - Sending emails from the machine with name of the HOSTNAME
 
Hi,

In my server I work with sendmail, for a long time I try to send emails from user "root" and get this mail with full name of the HOSTNAME machine. but in the from I only see "root" and not root@myhostname.com, when I add the LOCAL_USER(`root')dnl to /etc/mail/submit.mc file, it's work i see the root@myhostname.com but if I try to send mail from user "root" like - echo "bla" | mail -s "test" root i get this error: "root... User address required"

in addition, I use a file ".forward"

anybody know as a problem and know the solution ?

If there is a solution with "aliases" file, I like to see an example...

Thanks, Oz.

JSkywalker 03-15-2012 02:37 PM

http://www.linuxhomenetworking.com/w...x_Mail_Servers
the chapter "Using Sendmail to Change the Sender's Email Address " might be of interest....

or, kill sendmail, and stat using postfix :D

Oz. 03-18-2012 03:08 AM

Hi JSkywalker,
Thanks for the help...
it work's, but if I send mail from "root" user I get the mail from "root" and not from "root@e1.mydomain.com"
is there anything else you could recommend ?

thanks again,
Oren.

agentbuzz 03-18-2012 09:18 AM

sendmail masquerading
 
Oz,
There is a useful explanation of masquerading written by Eric Himself(tm) here.
It sounds like you need to use EXPOSED_USER(`usernames') or EXPOSED_USER_FILE(`filename') in your sendmail.mc to ensure that the hostname is not masqueraded for system messages. You shouldn't need to mess with submit.mc. You might consider starting with a clean source tree and building a new sendmail.cf having modified only your sendmail.mc.

Here is an easy cheat sheet for building sendmail and its config files.

Oz. 03-19-2012 04:05 AM

A quick question - I have noticed that system email arrive as sent from "root<root@e1.mydomain.com>", so in a way sendmail already adds the localhost.localdomain.
The problem is with the attached nickname (e.g. root<>), which makes it harder for us to read from cellular devices. Emails sent from other users arrive as sent from the raw address (e.g. "user@e1.wizaboo.com"). Do you have any idea how can we strip the nickname from the root user as well?

agentbuzz 03-19-2012 12:04 PM

sendmail address re-writing
 
Oz,
You can use the genericstable to re-write local addresses, both "From:" addresses and envelope addresses, to anything you choose. First, make the needed changes to your sendmail.mc:
Code:

FEATURE(genericstable, hash /etc/mail/genericstable)
GENERICS_DOMAIN(SERVER1.domain.com)
FEATURE(masquerade_envelope)

Then, from the location in your sendmail source tree that has both the sendmail.mc and a copy of the "Build" script, do a "./Build sendmail.cf". That will build a valid sendmail.cf, which you can drop into /etc/mail. Make sure to back up your original /etc/mail/sendmail.cf first. Next, build the /etc/mail/genericstable. It will have entries like this:
Code:

root:  root@SERVER1.domain.com
postgres:  postgres@SERVER1.domain.com

Do the following to create the keyed database with the M4 macro processor:
Code:

makemap hash /etc/mail/genericstable.db < /etc/mail/genericstable
You have to restart sendmail now. Not so that it can read genericstable.db, but to get it to re-read sendmail.cf.

Do something that causes system messages to be generated. Your sender address and envelope address should be masqueraded to the same address.

Oz. 03-20-2012 03:36 AM

Thanks,
I'll try to do it!

Thanks again :)
Oz.


All times are GMT -5. The time now is 04:25 AM.