[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2519
  • Last Modified:

Sendmail to Change the Sender's Email Address

HI
i configured sendmail .
i can send email without any probem but the email address appair like this fosiul@mail.mydomain.com  
but i want to appear as  fosiul@mydomain.com

i have done the following from this tutorial : http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch21_:_Configuring_Linux_Mail_Servers

i have edit my /etc/host  : 127.0.0.1   mail.mydomain.com mydomain.com loalhost ..


add these line in sendmail.mc  : FEATURE(`genericstable',`hash -o /etc/mail/genericstable.db')dnl
GENERICS_DOMAIN_FILE(`/etc/mail/generics-domains')dnl
Create 2 file : /etc/mail/generics-domains and /etc/mail/genericstable

but no luck ,
can any one tel lme where i am doing wrong ??

0
fosiul01
Asked:
fosiul01
  • 9
  • 5
  • 5
2 Solutions
 
arnoldCommented:
You need to set the environment variable in the shell to define the local domain as mydomain.com.

Also you can follow the masquerade section in the link you posted.

Note: the above might not alter the email address reflected on the From: line in the email message.
0
 
fosiul01Author Commented:
"You need to set the environment variable in the shell to define the local domain as mydomain.com. "
how will i do that ??
0
 
arnoldCommented:
Which application is being used to access email?  kdmail, mail, mailx, mutt, etc.?
You have to look at the global configuration usually in /etc/ to define the domain.

Have you looked at the masquerading section on the link you posted?
0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
fosiul01Author Commented:
ok this sendmail server will send email for couple of domian
example
abc.com , xyz.com

if i use masquerading, then it will send email only by one domain, but as i said, this server will send email for several domain.

your comments : Which application is being used to access email?  kdmail, mail, mailx, mutt, etc.?

i am trying to send email to any email server like yahoo , hotmail

your comments : You have to look at the global configuration usually in /etc/ to define the domain.

did you meant /etc/hosts ?? yes, as i said earlier its like this

i have edit my /etc/host  : 127.0.0.1   mail.mydomain.com mydomain.com loalhost ..

so when i am sending email to suppose gmail.com , its getting email like this , fosiul@mail.mydomain.com

but i want it to chagne fosiul@mydomain.com
0
 
arnoldCommented:
What are you using to compose the email?  sendmail is the transport/delivery agent.

/etc/hosts is not the issue.

if you are using kdmail, there might be kdmail.rc file where you define your email as fosiul@mydomain.com.  Depending on the application/program you use, you may have an option to simply have multiple email addresses to choose from when sending a message or you have to start the application using different configuration files where the difference will be the email address listed for you.

Even setting the confDomain you run into an issue where user@xyz.com does sends an email and it is reflected as user@zyx.com

http://www.sendmail.org/m4/tweaking_config.html
0
 
fosiul01Author Commented:
ommm ok,

yes i know, if i use outlook i would be able to change the header of the address from, fosiul@mail.mydomain.com to fosiul@mydomain.com

but i was trying to send mail from command prompt like this

cat /etc/test.txt | mail -s "test email" user@gmail.com

so in gmail.com the email received as fosiul@mail.mydomain.com

so if i try to send email like command prompt will it change the header from fosiul@mail.mydomain.com to fosiul@mydomain.com ??

i realy thought yes from that tutorial.
0
 
NopiusCommented:
1) Try first
Change the order of hostnames (and spell right localhost):

/etc/host  : 127.0.0.1   mail.mydomain.com mydomain.com loalhost

to

/etc/host  : 127.0.0.1   mydomain.com mail.mydomain.com localhost

and restart sendmail 'service sendmail restart' or reboot the machine, then try again

2) Read below if 1) doesnt work
Sendmail uses local hostname as a domain part of your address IF your mail message doesn't contain domain part in From: field (say the mail from 'root' or 'tony', not from 'root@domain.com').

Run 'hostname' command and check what is your hostname. So you may change your hostname to 'mydomain.com' and everything should work if the problem was in messages without domain part in From: field.

If you have 'MASQUARADE_AS' feature enabled, every outgoing message will have domain that was used in definition.http://www.sendmail.org/m4/masquerading.html
So even without changing the hostname you may use this feature to always rewrite outgoing mail to be as from @mydomain.com with the following config:
MASQUERADE_AS(`mydomain.com')
0
 
fosiul01Author Commented:
yes i understnad what you saying, if i use masquerade_as then it would be possible.

but the problem is , this mail server will send mail for different domain such as abc.com, xyz.com

now if i masquerade_as ('abc.com')
all email header will change to abc.com
but when i wil try to send email with xyz.com , i will stuck, is not it ?? because as a rule it will change the header to abc.com
0
 
arnoldCommented:
You need to configure mail.rc to reflect the correct sender's email address. /etc/mail.rc
What are the contents of /etc/test.txt?
If it is only the body of the message, add the To: From: Subject: and an empty lines above the text.
then run:
cat /etc/test.txt | /usr/bin/sendmail -oi -fosiul@mydomain.com -t
cat /etc/test.txt | /usr/bin/sendmail -oi -fosiul@mydomain.com user@gmail.com
0
 
fosiul01Author Commented:
ommm i think whats happenning here

as you said i need to add to and from before sending email

but with mail command how will i add From : ???

test.txt is nothing just an example file where i wrote" bla bla bla"
0
 
arnoldCommented:
Instead of mail check if you have mutt on the system if not, get mutt.
www.mutt.org apt-get mutt install yum install mutt depending which option is available to you.

You can try altering the order in the /etc/hosts as suggested by Nopius without restarting sendmail.
Also try using mail -I to see whether it offers you an option to specify the from address.(don't think it does, but just in case)

mail is a command line email client that does not offer many options.
0
 
fosiul01Author Commented:
I cant chagne /etc/host as it will create mail greeting problem. and before it created too much problem and my server was blocked as spam. so i cant take that risk.


but one thing i dont understand whats the point of this section

"Using Sendmail to Change the Sender's Email Address " of that tutorial, if this tutorial would work, my problem would of  solved aswell and  i followed that one, and but it dindot work for me
0
 
NopiusCommented:
> but with mail command how will i add From : ???

that's clarifies your question...
I agree with arnold, you should install another mail client, default 'mail' command is not good enougth and can't be used for specifying domain part for From: field.



> I cant chagne /etc/host as it will create mail greeting problem. and before it created too much problem and my server was blocked as spam. so i cant take that risk.

I understand what you are saying about... Your direct and reverse DNS should match and FQDN should be used in EHLO part of SMTP...

> but the problem is , this mail server will send mail for different domain such as abc.com, xyz.com
> now if i masquerade_as ('abc.com')
> all email header will change to abc.com

Did you read the posted above link?
that is from there:

Normally the only addresses that are masqueraded are those that come from this host (that is, are either unqualified or in class {w}, the list of local domain names). You can augment this list, which is realized by class {M} using

In your case (I suggest) in the class 'w' are only 'localhost', 'mail.mydomain.com' and no other 'from' domain will be changed BUT if you also have multiple domains in /etc/mail/local-domain/names, use this:
MASQUERADE_AS(`mydomain.com')
MASQUERADE_DOMAIN(`mail.mydomain.com')

0
 
NopiusCommented:
Also add the following feature:

FEATURE(`limited_masquerade')

> Normally, any hosts listed in class {w} are masqueraded. If this feature is given, only the hosts listed in class {M} (see MASQUERADE_DOMAIN) are masqueraded. This is useful if you have several domains with disjoint namespaces hosted on the same machine.

http://www.sendmail.org/m4/features.html
0
 
fosiul01Author Commented:
hi ya sorry due to night i had to loggoff

i went through the link

" The effect of this is that although mail to user@otherhost.domain will not be delivered locally, any mail including any user@otherhost.domain will, when relayed, be rewritten to have the MASQUERADE_AS address. This can be a space-separated list of names.

If these names are in a file, you can use
MASQUERADE_DOMAIN_FILE(`filename') "

so you saying, i will have to write all the domain name in a file

then use this  MASQUERADE_DOMAIN_FILE(`filename') "   ??

0
 
NopiusCommented:
Hi again, fosiul01

> so you saying, i will have to write all the domain name in a file
> then use this  MASQUERADE_DOMAIN_FILE(`filename') "   ??

No, you don't have to do it. The minimum set of config rules is:

FEATURE(`limited_masquerade')
MASQUERADE_AS(`mydomain.com')
MASQUERADE_DOMAIN(`mail.mydomain.com')


You also don't have to define MASQUERADE_DOMAIN_FILE(`filename').
If would be useful only if you have multiple incorrect outgoing domains, say user@mail1.domain.com and user2@mail2.domain.com and like to masquarade them both as from @domain.com, only then you might to use filename...

0
 
fosiul01Author Commented:
0
 
NopiusCommented:
That question is deleted and can't be viewed...
0
 
fosiul01Author Commented:
hi Nopius thanks
i have solved that problem, so i deleted that one
thanks anyway
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 9
  • 5
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now