LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Easy question on mail (https://www.linuxquestions.org/questions/linux-networking-3/easy-question-on-mail-36856/)

jkcunningham 11-29-2002 10:46 PM

Easy question on mail
 
I'm sure this is an easy question: how do I change the return address to something real when I use 'mail' from the commandline?

I have an external mail server with the account jeffrey@cunningham.net. I lease this account. It is a POP and SNTP account. At home I route this using fetchmail so that I read it with kmail. In kmail I have defined the correct email return address. But if I send mail from a script or the commandline this way:

>mail somebody@somewhere -s "test" </dev/null

the return address that is embedded in my email is jeffrey@localdomain.net

How can I change this to show the correct return address? I checked the man pages on sendmail, procmail, fetchmail, mail, aliases, and a couple others and haven't stumbled on it yet.

Thanks.

Jeff

KevinJ 11-29-2002 11:38 PM

I think you have to make a ".mailrc" file in your home directory and put a line something like this in there:

set fromline="John Doe <John.Doe@somedomain.com>"

But quite frankly, there are much better commandline mail programs than "mail".

I use "Pine", but there is also "Elm" and "EMACS".
Pine has a configuration option that will allow you to set the return address.

-K .

jkcunningham 11-30-2002 12:53 PM

Thanks for the reply, Kevin. But I've searched in vain for a .mailrc setting like you suggest. For example, here is a description of the .mailrc file format, and no mention in it of a way to set the 'replyto' address:

http://www.unet.univie.ac.at/aix/fil...tm#CN33140kaye

On my system (Suse8.1) there is an /etc/mail.rc file which contains nothing useful that I can see:

set asksub append dot save crt=20
ignore Received Message-Id Resent-Message-Id Status Mail-From Return-Path Via

I have found that in the /etc/postfix/main.cf file, if I change:

mydomain=cunningham.net
myorigin=$mydomain

I have at least corrected the domain part of both the reply to and from addresses. However, the username is that of my local account (jcunningham), not my mail account (jeffrey). How can I make it prepend my mail account name to the mail domain instead of my local account?

The reason for using mail in my current situation is not preference, its legacy: there are a large body of scripts where I work already set up to use mail to send notifications when certain stages of processing are completed. I don't own all the scripts and don't want to try changing them if I can help it. These scripts are shared and must remain so.

Thanks,

-Jeff

jkcunningham 11-30-2002 04:50 PM

It took me about five minutes to configure mutt to do what I wanted. Something like this is definitely the way to go. Now I have to figure out how to get the other people involved to change the common scripts. Thanks.

-Jeff

KevinJ 12-01-2002 10:28 AM

If you don't have a ".mailrc" file in your home directory, you need to make one. Then put that line in it that I wrote above.

-K.

jkcunningham 12-01-2002 11:48 AM

I did make one, Kevin. It ignores the line. Here's my .mailrc:

set replyto="jeffrey@cunningham.net"
set fromAddress=1
alias test jeffrey@cunningham.net

I know its reading the file, because the test alias works. But both the replyto and from addresses show up as <username>.cunningham.net rather than jeffrey@cunningham.net

peter_robb 12-01-2002 12:35 PM

The Postfix setup will have a similar setting to sendmail where certain priveleged users are allowed to do domain rewriting...

Key is to find it...

jkcunningham 12-01-2002 12:54 PM

I'll look in that direction, Peter.
Thanks. But I succeeded in changing the domain by setting

mydomain=cunningham.net
myorigin-$mydomain

in /etc/postfix/main.cf. What I haven't figured out yet is how to set the username. It prepends the user account name to the domain for both the replyto and from lines, instead of the username at cunningham.net.

Regards,

KevinJ 12-01-2002 01:57 PM

what about "set fromline= ... " did you try that?

-K.

jkcunningham 12-01-2002 04:44 PM

Yes, I did try "set fromline=...", but it didn't work either. Also, I could find no documentation for that set option, or anything like it in the man pages.

jkcunningham 06-03-2003 09:05 AM

For future reference, in most cases you can set your return address with the .bashrc environment variables:

export EMAIL=someone@somewhere.net
export REPLYTO=${EMAIL}

but for obscure reasons, this may be overridden elsewhere. I ended up abandoning the mail utility largely because everyone advised me to - its not well supported anymore apparently.

You can use mutt from scripts or the commandline like this:

> mutt -x someone@somewhere.net -s "subject sentence" </dev/null

You may be able to do attachments with an additional -a filename, but I haven't tried it. You set your reply to address and everything else you want to show up or happen in ~/.muttrc

I've been using metamail for scripting emails with attachments.

-Jeff

JunctaJuvant 08-20-2003 11:34 AM

Hi,

I had a somewhat similar problem, and consequently ended up here in search of a solution. Finding none, I "solved" it by including the following alias in my .bashrc;

alias m="mail -r 'Your Name <yourname@isp.com>'"

Note the single quotes.

This has the following effect on the recipient's 'From:' field;

From: "Your Name" <yourname@isp.com>

This obviously doesn't solve the non-functioning of "set replyto='you@whereever.com'" and no doubt there's a better solution, but this has worked fine for me and saves typing :)

With regards,

JJ


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