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 the below, but it didnt work for me. Please help me it is urgent.

hdr="To:xxxx@xxx.com\nFrom:something<xxx@xxx.com>\n\n"
emailbody="something"
echo "${hdr}${emailbody} | mailx -t -s "subject field"

Thanks in Advance.

Most OS support the .mailrc file. Utilize the alias feature to define what you need.

Solaris: Mail Aliases (Solaris Advanced User's Guide) - Sun Microsystems
AIX: Help -
Linux: various

Hi Tpietschmann,

Actually I want to see the senders name in my mail box rather than showing the email.

for example:

if i am sending a email from vamsi@xxxxx.com to my email box. What I want to see in my mail box is "mail from vamsi krishna" not the entire vamsi@xxxx.com.

through header I am able to set the cc and bcc etc but not the from.

I hope you understand my problem.

thanks,
Vamsi K Surampalli.

Try changing your header:

hdr="To:xxxx@xxx.com\nFrom: \"vamsi krishna\" <xxx@xxx.com>\n\n"

Hi tpietschmann,

It didnt work for me... :frowning:
Vamsi.

Not sure if I understand the question/issue but why don't use the mailx -r option and set the email address there?

Ex.
echo "Hello"|mailx -r xxx@xxx.com -s "subject field" torecipient(s)