LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 07-24-2007, 04:19 AM   #1
ALInux
Member
 
Registered: Nov 2003
Location: Lebanon
Distribution: RHEL 5/CentOS 5/Debian Lenny/(K)Ubuntu Is Dead/Mandriva 10.1
Posts: 676
Blog Entries: 7

Rep: Reputation: 32
Change sender address of outgoing emails in Sendmail


Hi all
Whenever my logwatch application sends me emails it sends them out using root@localdomain.localhost..the thing is I do not want to change the current config in /etc/hosts but I do wish for emails sent through root to be sent as root@b.c for example.
Any guidance please ?
 
Old 07-25-2007, 01:28 PM   #2
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,824

Rep: Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615
What distribution?

Try putting "b.c" in /etc/mailname. If your distro is Debian or Debian-like that should do it; if not, I know not whether that will work or not.
 
Old 07-25-2007, 01:47 PM   #3
michaelnel
LQ Newbie
 
Registered: Apr 2005
Location: San Francisco, California
Posts: 12

Rep: Reputation: 0
The default is to mail to root. If you want it to mail to root@yourdomain.com then change /etc/logwatch/conf/logwatch.conf so it says:

MailTo = root@yourdomain.com

Last edited by michaelnel; 07-25-2007 at 01:51 PM.
 
Old 07-25-2007, 03:20 PM   #4
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,824

Rep: Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615
Clarification please, OP: Is the mail going to the wrong address or is it appearing to be from the wrong address?
 
Old 07-26-2007, 01:33 AM   #5
ALInux
Member
 
Registered: Nov 2003
Location: Lebanon
Distribution: RHEL 5/CentOS 5/Debian Lenny/(K)Ubuntu Is Dead/Mandriva 10.1
Posts: 676

Original Poster
Blog Entries: 7

Rep: Reputation: 32
The distro is RHEL3..the outgoing address is root@localhost.localdomain ..I want it to appear as root@myhost.com without having to set myhost in the /etc/hosts file
 
Old 07-26-2007, 10:13 AM   #6
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,824

Rep: Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615
Okay, did you try /etc/mailname?
 
Old 08-02-2007, 11:14 AM   #7
yog54
LQ Newbie
 
Registered: Aug 2007
Posts: 3

Rep: Reputation: 3
Wink The answer!!!

I had the same problem, and i found the solution in:
http://www.linuxhomenetworking.com/w..._Email_Address

I copy the solution here just in case

#########FROM LINUXHOMENETWORKING.COM#############

Using Sendmail to Change the Sender's Email Address

Sometimes masquerading isn't enough. At times you may need to change not only the domain of the sender but also the username portion of the sender's e-mail address. For example, perhaps you bought a program for your SOHO office that sends out notifications to your staff, but the program inserts its own address as sender's address, not that of the IT person.

Web-based CGI scripts tend to run as user apache and, therefore, send mail as user apache too. Often you won't want this, not only because apache's e-mail address may not be a suitable, but also because some anti-spam programs check to ensure that the From:, or source e-mail address, actually exists as a real user. If your virtusertable file allows e-mail to only predefined users, then queries about the apache user will fail, and your valid e-mail may be classified as being spam.

With sendmail, you can change both the domain and username on a case-by-case basis using the genericstable feature:

1) Add these statements to your /etc/mail/sendmail.mc file to activate the feature:

FEATURE(`genericstable',`hash -o /etc/mail/genericstable.db')dnl
GENERICS_DOMAIN_FILE(`/etc/mail/generics-domains')dnl

2) Create a /etc/mail/generics-domains file that is just a list of all the domains that should be inspected. Make sure the file includes your server's canonical domain name, which you can obtain using the command:

sendmail -bt -d0.1 </dev/null

Here is a sample /etc/mail/generics-domains file:

my-site.com
another-site.com
bigboy.my-site.com

3) Create your /etc/mail/genericstable file. First sendmail searches the /etc/mail/generics-domains file for a list of domains to reverse map. It then looks at the /etc/mail/genericstable file for an individual email address from a matching domain. The format of the file is

linux-username username@new-domain.com

Here is an example:

alert security-alert@my-site.com
peter urgent-message@my-site.com
apache mailer@my-site.com

4) Run the sendmail restart script from the beginning of the chapter and then test.

Your e-mails from linux-username should now appear to come from username@new-domain.com.


#######################################################



Good luck.
 
3 members found this post helpful.
Old 05-10-2012, 06:08 PM   #8
shafty023
Member
 
Registered: Oct 2007
Distribution: OSX
Posts: 248

Rep: Reputation: 31
I'm not sure if the OP wanted to do this on a per email basis or permanently so below is how to change it on a per email basis.

Code:
echo "testing" | sudo sendmail -f "fromuser@domain.com" touser@domain.com
You use the "-f" switch to change the FROM address.
 
1 members found this post helpful.
Old 05-10-2012, 06:25 PM   #9
michaelnel
LQ Newbie
 
Registered: Apr 2005
Location: San Francisco, California
Posts: 12

Rep: Reputation: 0
May I borrow your time machine?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
qmail: how can I block emails which have no sender address? hamish Linux - Networking 0 08-16-2006 04:16 PM
saving outgoing emails in sendmail sqn Linux - Software 1 07-26-2006 07:26 AM
Sendmail - outgoing emails have Machine name hunter44102 Linux - Networking 2 09-13-2004 07:52 PM
sendmail delay with outgoing emails Stefanie71 Linux - Newbie 1 06-30-2004 03:26 PM
Help with Sendmail filters for outgoing mail by sender/recipient gljoe Linux - Software 18 08-12-2003 08:56 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 08:01 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration