LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 11-29-2002, 10:46 PM   #1
jkcunningham
Member
 
Registered: May 2002
Location: Seattle, WA, USA
Distribution: Gentoo
Posts: 136

Rep: Reputation: 15
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
 
Old 11-29-2002, 11:38 PM   #2
KevinJ
Member
 
Registered: Feb 2001
Location: Colorado Springs, CO
Distribution: Redhat v8.0 (soon to be Fedora? or maybe I will just go back to Slackware)
Posts: 857

Rep: Reputation: 30
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 .
 
Old 11-30-2002, 12:53 PM   #3
jkcunningham
Member
 
Registered: May 2002
Location: Seattle, WA, USA
Distribution: Gentoo
Posts: 136

Original Poster
Rep: Reputation: 15
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
 
Old 11-30-2002, 04:50 PM   #4
jkcunningham
Member
 
Registered: May 2002
Location: Seattle, WA, USA
Distribution: Gentoo
Posts: 136

Original Poster
Rep: Reputation: 15
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
 
Old 12-01-2002, 10:28 AM   #5
KevinJ
Member
 
Registered: Feb 2001
Location: Colorado Springs, CO
Distribution: Redhat v8.0 (soon to be Fedora? or maybe I will just go back to Slackware)
Posts: 857

Rep: Reputation: 30
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.
 
Old 12-01-2002, 11:48 AM   #6
jkcunningham
Member
 
Registered: May 2002
Location: Seattle, WA, USA
Distribution: Gentoo
Posts: 136

Original Poster
Rep: Reputation: 15
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
 
Old 12-01-2002, 12:35 PM   #7
peter_robb
Senior Member
 
Registered: Feb 2002
Location: Szczecin, Poland
Distribution: Gentoo, Debian
Posts: 2,458

Rep: Reputation: 48
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...
 
Old 12-01-2002, 12:54 PM   #8
jkcunningham
Member
 
Registered: May 2002
Location: Seattle, WA, USA
Distribution: Gentoo
Posts: 136

Original Poster
Rep: Reputation: 15
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,
 
Old 12-01-2002, 01:57 PM   #9
KevinJ
Member
 
Registered: Feb 2001
Location: Colorado Springs, CO
Distribution: Redhat v8.0 (soon to be Fedora? or maybe I will just go back to Slackware)
Posts: 857

Rep: Reputation: 30
what about "set fromline= ... " did you try that?

-K.
 
Old 12-01-2002, 04:44 PM   #10
jkcunningham
Member
 
Registered: May 2002
Location: Seattle, WA, USA
Distribution: Gentoo
Posts: 136

Original Poster
Rep: Reputation: 15
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.
 
Old 06-03-2003, 09:05 AM   #11
jkcunningham
Member
 
Registered: May 2002
Location: Seattle, WA, USA
Distribution: Gentoo
Posts: 136

Original Poster
Rep: Reputation: 15
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
 
Old 08-20-2003, 11:34 AM   #12
JunctaJuvant
Member
 
Registered: May 2003
Location: Wageningen, the Netherlands
Distribution: OS X & Linux Mint
Posts: 488

Rep: Reputation: 31
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
 
  


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
easy to setup internal mail server for small company nickcol Linux - Software 3 04-21-2005 06:24 PM
Easy urpmi ,no easy send mail. akihandyman Linux - General 2 12-27-2004 02:15 PM
Easy question snowbird122 Linux - Newbie 2 09-11-2004 11:10 PM
easy mail server? viniosity Linux - Software 4 12-15-2003 09:52 PM
Easy Mail Server for 6-10 users? MikHud Linux - Software 6 02-15-2003 11:24 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 01:43 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