Operating System - HP-UX
1823184 Members
3631 Online
109647 Solutions
New Discussion юеВ

Re: Changing the "From" address when emailing non-text MIME attachments from command line.

 
SOLVED
Go to solution
Stuart Allan
Occasional Contributor

Changing the "From" address when emailing non-text MIME attachments from command line.

I've read through the numerous threads on sendmail, mailx, mpack and elm but haven't found a suitable answer yet.

Our developers have been using uuencode and sendmail with the -f flag to send attachments and also specify a different "From" address for the email.

When they tried sending these attachments to Exchange mail servers this didn't work. I suggested using elm as this is MIME compatible, which works for the attachments but doesn't seem to allow you to change the "From" address at command line. You can specify a "From" address in the elmheaders file but all these users share the same .elm home directory and there can be multiple email instances with various "From" addresses running at the same time.

You can also specify a "From" address in elm interactive mode but these emails are generated by programs so it needs to be a command line option.

I've also tried mailx and mpack. Again non-text MIME attachments work with these but I can't find how to change the "From" addresses.

Any suggestions as to:
either
1) how can I email non-text MIME attachments from sendmail so that I can used with the -f flag to change the "From" address,
or
2) how can I change the "From" address on the command line for mailx, elm or mpack?
or
3) other alternatives

TIA
Stuart.



3 REPLIES 3
Bill Hassell
Honored Contributor
Solution

Re: Changing the "From" address when emailing non-text MIME attachments from command line.

It's not clear in the mailx man page but the -r option will allow you to change the From address.


Bill Hassell, sysadmin
Steven Sim Kok Leong
Honored Contributor

Re: Changing the "From" address when emailing non-text MIME attachments from command line.

Hi,

To send an email from a specific From: address ($SENDER_ADDRESS) of a MIME type (in this example, I use text/html to send html-embedded emails), you can make use of SMTP commands over an SMTP connection.

$MAIL_SERVER, $SENDER_ADDRESS, $RECEIPIENT_ADDRESSES, $EMAIL_TEXT are variables you should substitute accordingly.

Here is a template example:

# telnet $MAIL_SERVER 25
mail from: $SENDER_ADDRESS
Sender ok
rcpt to: $RECEIPIENT_ADDRESSES
Recipient ok
data
From: $SENDER_ADDRESS
To: $RECEIPIENT_ADDRESSES
Subject: XXX YYY ZZZ
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
MIME-Version: 1.0
$EMAIL_TEXT
.

Hope this helps. Regards.

Steven Sim Kok Leong
Brainbench MVP for Unix Admin
http://www.brainbench.com
Volker Borowski
Honored Contributor

Re: Changing the "From" address when emailing non-text MIME attachments from command line.

Hi,
this is a way that worked for me:

( echo Subject: Hello
echo From: nobody@nowhere
echo This is a nice Mail with attachment !
uuencode /tmp/hosts /tmp/hosts ) | sendmail volker.borowski@whereever.com

Forums ref and special thanks to Robin Wakefield
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x62f2c6af36b7d5118ff10090279cd0f9,00.html

Volker