LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 03-28-2014, 01:19 AM   #1
trickynapzter
LQ Newbie
 
Registered: May 2011
Posts: 19

Rep: Reputation: 0
Change Sender name using mail in Centos 6


Hi All,


My problem is regarding how to change the senders name when sending an email after series of command in script. This is how i send email:

Code:
echo -e "$MSG" | mail -s " - [awesomedomain.com]: Failed call on [$CHANNEL] -" "$EMAIL"
When i received that email it come from a name Asterisk VoIP PBX, i wanted it to be customized like "Company PBX". Is there any chance to change the senders name using the mail command in CentOS 6?
 
Old 03-28-2014, 03:10 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,165
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Hi,

You can either set the from variable to the sender address you want:
Code:
export from=sender@domain.com
echo -e "$MSG" | mail -s " - [awesomedomain.com]: Failed call on [$CHANNEL] -" "$EMAIL"
or use the -r switch (might not work in some mail versions)
Code:
echo -e "$MSG" | mail -s " - [awesomedomain.com]: Failed call on [$CHANNEL] -" -r sender@domain.com "$EMAIL"
Regards
 
1 members found this post helpful.
Old 03-30-2014, 02:12 AM   #3
trickynapzter
LQ Newbie
 
Registered: May 2011
Posts: 19

Original Poster
Rep: Reputation: 0
hi thank you for your reply, -r works for me but how do you change the senders name? the code will only add the senders email address.

Code:
echo -e "$MSG" | mail -s " - [awesomedomain.com]: Failed call on [$CHANNEL] -" -r sender@domain.com "$EMAIL

I want to modify the senders name for example, it would appear in your inbox as "Company PBX" and yes it's still coming from sender@domain.com.
 
Old 03-30-2014, 08:39 AM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,165
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
Originally Posted by trickynapzter View Post
hi thank you for your reply, -r works for me but how do you change the senders name? the code will only add the senders email address.

Code:
echo -e "$MSG" | mail -s " - [awesomedomain.com]: Failed call on [$CHANNEL] -" -r sender@domain.com "$EMAIL

I want to modify the senders name for example, it would appear in your inbox as "Company PBX" and yes it's still coming from sender@domain.com.
So you can use the following syntax:
Code:
echo -e "$MSG" | mail -s " - [awesomedomain.com]: Failed call on [$CHANNEL] -" -r "sender@domain.com (Company PBX)" "$EMAIL
Regards
 
1 members found this post helpful.
Old 03-30-2014, 09:00 AM   #5
trickynapzter
LQ Newbie
 
Registered: May 2011
Posts: 19

Original Poster
Rep: Reputation: 0
Thumbs up

you are genius it works like a charm... thank you so much bathory.. problem solved
 
  


Reply

Tags
mail



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
mailx change sender name hudac Linux - Software 11 02-03-2013 07:13 PM
Trying to set up E-Mail sender Libra RHR Linux - Software 2 09-07-2008 03:52 PM
cannot send mail using Mail::Sender cccc Programming 2 11-02-2007 02:27 AM
Specify mail sender? spiffytech Linux - Networking 1 01-23-2006 11:40 AM
Configure sender's mail id. bharaniks Linux - Software 0 07-27-2005 05:35 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

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