LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 11-26-2014, 05:41 AM   #1
jackiebaron
Member
 
Registered: Aug 2011
Posts: 51

Rep: Reputation: Disabled
How to change the "From" field in sendmail


Hi,

I have to generate an email report that runs at regular intervals...no problem.
But I want to specify a "From" field.

I execute the command sendmail <recipient address> < mailbody.txt

Now in the file mailbody.txt I have the following:

Subject: Daily Report
From: "the messenger"
To: <group email address>

....and then the body of text.

It sends the report nicely and the subject appears as the email subject BUT it's always from "the messenger"@admin@localdomain.com or something like that. I would just like it to be something exactly as I type in (somewhere) like
From: The Bean Counter, or
From: Mission Control

or something like that.

Thanks for any guidance.
 
Old 11-26-2014, 07:42 AM   #2
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,461

Rep: Reputation: 1552Reputation: 1552Reputation: 1552Reputation: 1552Reputation: 1552Reputation: 1552Reputation: 1552Reputation: 1552Reputation: 1552Reputation: 1552Reputation: 1552
Do some reading on:

Code:
sendmail -f
sendmail -r
You will also have to be a trusted sender to change the from/reply-to stuff.
 
Old 11-26-2014, 08:11 AM   #3
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
You can do it all by piping multiple lines into "sendmail -t"

(echo "To: <recipient@example.com>"
echo "From: the messenger"
echo -e "Subject: Test email \n"
echo -e "Line 1 of body in test \n"
echo -e "Line 2 of body in test \n") |sendmail -t

Note that whatever you put in the From: will have the domain of the server appended as @<server.example.com> unless you put in the "@" yourself. (e.g. "the messenger@wherever"). Also If you have spaces in the From: it will replace those with dots so it becomes "the.messenger". You could replace the spaces with underscores. (e.g. "the_messenger")
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Grabbing the last field of a delimited entry without using "awk" or "sed" drandre Linux - Newbie 17 04-18-2012 10:54 PM
""Header Field was corrupted"" uetian Linux - Software 1 08-20-2011 02:55 AM
How to change " setenv IDLUTILS_DIR ~/idl/idlutils" to "export"?? msbstar Linux - Newbie 3 02-05-2011 04:23 AM
2 specific Sendmail questions about "delay_checks" and "Connect:" in access.db fast-reflexes Linux - Server 0 08-05-2010 09:33 AM
Fedora Core 2: Screen Resolution can not change from "800X600" to "1024X 768" suhaimi_sj Fedora - Installation 18 12-17-2009 03:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:02 AM.

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