LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Change sendmail's sender address (http://www.linuxquestions.org/questions/linux-newbie-8/change-sendmails-sender-address-814781/)

rjo98 06-17-2010 03:10 PM

Change sendmail's sender address
 
We're using mutt to send out a daily email through cron. The only problem is that half the people aren't getting it, because its getting rejected as coming from an invalid address. Right now its sending out as username@localhost.localdomain.

How can I change this? I found the sendmail.cf, which I believe previous people have been editing directly, which from what I read isn't the best way to configure sendmail.

Also, this is the first time i've actually tried to do anything with sendmail, so sorry if this is a real basic question.

rweaver 06-17-2010 03:40 PM

You want to add the features:
MASQUERADE_AS(`hostname.domain.tld')
and
FEATURE(`masquerade_envelope')

To your sendmail config

rjo98 06-17-2010 06:11 PM

Hi rweaver. Do I just VI the file and add those at the end?

rjo98 06-17-2010 10:13 PM

I looked in my sendmail.cf and I do not have lines like that commented out, so if anyone can tell me how and where to add them, it would be greatly appreciated.

rjo98 06-18-2010 09:23 AM

or is there a switch i can use for mutt to have it use the sender address i want?

bathory 06-18-2010 09:48 AM

Quote:

Originally Posted by rjo98 (Post 4007499)
or is there a switch i can use for mutt to have it use the sender address i want?

You can set the env. variable EMAIL before running mutt, e.g.
Code:

export EMAIL=me@mydomain.com
mutt -s "Subject" recipient@domain.com ...

BTW rweaver means is, that you have to use those features in your sendmail.mc and then rebuild sendmail.cf. You can use google for tutorials about sendmail masquerading

Regards

rjo98 06-18-2010 09:52 AM

Hi Bathory, thanks for replying.

I tried to do what you said but it errors on the export line, saying "export: command not found". when i look in my /etc/passwd my account is set to /bin/tcsh if that might be the problem.

Also, using your solution once i get past that export error, do i need to modify the sendmail.cf? I think people have been directly modifying the .cf file rather than .mc so i'm afraid to regenerate the .cf.

rjo98 06-18-2010 09:56 AM

Wait, I think it worked, i just had to type bash, then enter the commands.

but if i wanted to cron this without changing the default shell for the user, do i just add a line that says bash before the two you provided, then finish it with a line stating exit?

bathory 06-18-2010 09:57 AM

Oops, export is used for the bash shell. In your case I guess you need setenv
Code:

setenv EMAIL my@mydomain.com
You don't modify sendmail.cf directly. You modify sendmail.mc and based on that you rebuild sendmail.cf.
It would be better use masquerade, but since you don't want to, then go with the EMAIL workaround

Regards

rjo98 06-18-2010 10:01 AM

I'm new to sendmail and have read you don't modify that file directly, but the people before me have, so i'm kinda hosed.

I'll try the sentenv too to see if that works.

bathory 06-18-2010 10:11 AM

There are little things you can modify directly in sendmail.cf. Most modifications are done through sendmail.mc

Anyway if you are going to use mutt in cronjob, mind that cron's environment could be different that the user's whose cronjob is run. So you have to use a script to define the variable and run mutt.

rjo98 06-18-2010 10:12 AM

Looks like both options you gave me work in the two shells, so either way i think i should be set!! thanks a TON bathory.

rjo98 06-18-2010 12:21 PM

bad news, while it looks like its coming from the address, when i look at the header info its still coming from the generic stuff in my original post, so its getting rejected by outside sources.

any other thoughts?

bathory 06-18-2010 01:12 PM

Hi,

Another workaround is to create a ~/.muttrc for the user that runs the cronjob, containing:
Code:

set envelope_from=yes
set from="me@mydomain.com"

Once again the best thing to do is masquerading, because the above workarounds are specific for mutt, so other programs like mail(x) are not going to work.

rjo98 06-18-2010 01:23 PM

we only use mutt to send the emails out, so i will try this and post back my results. thanks again bathory!!


All times are GMT -5. The time now is 05:24 AM.