Adding 'from' email address alias in Linux.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Adding 'from' email address alias in Linux.
# 1  
Old 05-30-2014
RedHat Adding 'from' email address alias in Linux.

Hi Experts,

We want to add the 'from' email address to mailx command in all our linux script. After searching this site I am able to find the command '-- -f' to add the from the email address. Bu the problem is our from email address is :- "Proper Support Name <support@company.com>"
Now when I am running mailx command I am getting email from 'support@company.com', but I need to have "Proper Support Name" (alias).

Could you please let me know how can we add the email alias ("Proper Support Name" in this case) in the from email address?
Command which I tried so far:-


Code:
mailx  -s  "`hostname` : ${Subj}" ${list} -- -f "From: \"Proper Support Name \" <support@company.com> \n\n" < 1.txt

mailx  -s  "`hostname` : ${Subj}" ${list} -- -f "Proper Support Name<support@company.com>" < 1.txt

mailx  -s  "`hostname` : ${Subj}" ${list} -- -f "Proper Support Name"<support@company.com> < 1.txt

# 2  
Old 05-31-2014
The sendmail compatibility options `-F' and `-f' after `--' do not appear to be in mailx anymore.
man mailx do not show any longer [-- sendmail-options ...]

However, looking at it, it appears to have an -S from= variable that you can use for the same purpose.

See if this will help
Code:
mailx -s "`hostname` : ${Subj}" -S "from=Proper Support Name <support@company.com>" ${list} < 1.txt

Make sure that you do not add the recipient anywhere else but as the last argument or it will fail. I am assuming that it is ${list}
# 3  
Old 05-31-2014
Code:
mailx -s "Subject" -r "from_address@test.com" "to_address@test.com"

# 4  
Old 05-31-2014
Quote:
Originally Posted by SriniShoo
Code:
mailx -s "Subject" -r "from_address@test.com" "to_address@test.com"

mailx -r does set as well the Return-Path which may or may not be what is wanted, and if the format "Name Title <me@here.com>" is given as requested, the Return-Path gets <me@here.com> which is not valid.

As per the documentation:

Quote:
-r address
Sets the From address. Overrides any from variable specified in
environment or startup files. Tilde escapes are disabled. The
-r address options are passed to the mail transfer agent unless
SMTP is used. This option exists for compatibility only; it is
recommended to set the from variable directly instead.
# 5  
Old 06-02-2014
Thanks all for the help!

Aia,

I have tried the "-S" option, but the command is failing with error message as
Code:
mailx: invalid option -- S
Usage: mail [-iInv] [-s subject] [-c cc-addr] [-b bcc-addr] to-addr ...
            [-- sendmail-options ...]

and yes, you are right '-r' option is not available... Smilie

Appreciate all your help!!
# 6  
Old 06-02-2014
Quote:
Originally Posted by Amey Joshi
Thanks all for the help!

Aia,

I have tried the "-S" option, but the command is failing with error message as
Code:
mailx: invalid option -- S
Usage: mail [-iInv] [-s subject] [-c cc-addr] [-b bcc-addr] to-addr ...
            [-- sendmail-options ...]

and yes, you are right '-r' option is not available... Smilie

Appreciate all your help!!
It appears that your mailx program is not a real binary but rather a symbolic link to the mail program. Futher more, your mail binary supports the compatible sendmail options. Are you in redhat 5.x?

Anyway, in that case your initial try was close.
Code:
mailx -s  "`hostname` : ${Subj}" ${list} -- -F"Proper Support Name" < 1.txt

# 7  
Old 06-05-2014
Yes, we are on Redhat Linux 5.8

Found a workaround, instead of using mailx command we used 'sendmail' command.
From sendmail it is easy to mention the 'from' email address. Smilie

Code:
(
 echo "From: ${from1}"
 echo "Subject: ${Subj}"
cat 1.txt
) | /usr/sbin/sendmail ${list}

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Post Here to Contact Site Administrators and Moderators

VIP Membership - The UNIX and Linux Forums - Get Your UNIX.COM Email Address Here

We work hard to make The UNIX and Linux Forums one of the best UNIX and Linux knowledge sources on the net. The site is certainly one of the top UNIX and Linux Q&A sites on the web. In order to provide certain members the best quality account services, you can now get some great extra features by... (2 Replies)
Discussion started by: Neo
2 Replies

2. Forum Support Area for Unregistered Users & Account Problems

Cant use certain email address

I tried to re-register using my new email address which is <firstname>@<surname>.me But it never sent out the email confirmation. I had to hit the back button and use my gmail address instead and it came through instantly. Is there a problem with using .me addresses? (1 Reply)
Discussion started by: frustin
1 Replies

3. Red Hat

Postfix - want to send email to some non-existent user using alias

Hi, I know how to use email redirection using /etc/aliases file + postfix combination and it is working fine for existing users. The question I have is: I want to send an email to tony@server1.example.com while tony user is actually not there. Rather, I want to redirect that email to... (0 Replies)
Discussion started by: freebird8z
0 Replies

4. Emergency UNIX and Linux Support

Bad Address when adding system call

Hi guys. I have downloaded kernel 2.6.38-5 to add a system call. I did the following steps: 1. I have added my system call to system call table <src folder>/arc/x86/kernel/syscall_table_32.S .long sys_mycall 2. i have added the system cal number in <src... (5 Replies)
Discussion started by: majid.merkava
5 Replies

5. Shell Programming and Scripting

Changing the sender Email address to Alias

Hi All, I want to change the email address of the sender to some alias for eg: FROM:noreplyecommerce@test.com needs to be changes to TEST Please help me. (3 Replies)
Discussion started by: sithara
3 Replies

6. UNIX for Advanced & Expert Users

Send email using alias name through mailx

Hi, My requirement is I have to send email using mailx command and the recipient of the mail should see a alias instead of email address in his mail box. The same functionality that we get when we sent email using an address book. Is this functionality possible through mailx? I tried doing... (5 Replies)
Discussion started by: vamsisurampalli
5 Replies

7. UNIX for Dummies Questions & Answers

redirection to email address

Can someone please tell me the format to redirect an output file to an email address? thanks (4 Replies)
Discussion started by: 4Given
4 Replies

8. Shell Programming and Scripting

adding a new alias to Aliases

when we invoke a line we write alias aliasname " " but i have on the original line "specific string" so it must be alias aliasname " "specific string" " and it cause me trouble what can i do ? (5 Replies)
Discussion started by: eynkesef
5 Replies

9. UNIX for Dummies Questions & Answers

Send email where # is in the email address - Using Unix

Hi All, How do I send an email using malix where email address contains a #. I have a email address like this : #test@test.com I want to send email like malix -s "TEST" #test@test.com < SOMEFILE I tried \# but doesn't work. Please let me know how we can achieve this? I am in... (1 Reply)
Discussion started by: jingi1234
1 Replies
Login or Register to Ask a Question