How to send a PDF attachment via MAILX?

Hi,

We are using HPUX and have a script to send PDF attachment via MAILX
Basically the script does the following:

echo > $HOME/MY_mail_file
uuencode o40881754.pdf o40881754.pdf  >> MY_mail_file
cat MY_mail_file | mailx -m -s "Sending PDF attachment"  <email address> 

This script works fine when sensing the attachment to MS Outlook or Gmail,
but it does not work when using Yahoo mail, we see the PDF attachment but when we try to retrieve it, it fails indicating an invalid format. It appears that Yahoo mail does not know how to decode the attachment done via uuencode.
.
I've been reading different notes regarding this issue, one suggestion was to use "mutt" but unfortunate it does not seem available for HPUX.
.
I've also tried MIME/base64 code that I found on different forums but it did not work either.
.
Has anyone been able to send PDF attachment to Yahoo mail via a Unix command line (ex: Mailx, Sendmail etc..) ?
If so how was this achieved ?
.
Thanks in advance

More and more mail clients are abandoning uuencode these days.

Try the uuencode -m option if you have it.

Thanks for the info
.
We were able to get it to work with a similar piece of code using MIME base64 and sendmail.
But we need to know when an email failed because of an invalid address and was not able to figure it out using sendmail. I also tried "-N failure" but still could not get it to work.
When using "mailx -r" we get an email notification when it failed, but the attachment is not sent properly. When we use "sendmail" the attachment works fine but we don't know if the email failed or not.
.
We also tried "mpack" which worked great with the attachments but were not able to get a notification on a failure for an invalid address.

Any suggestions ?
Thanks

What is the exact sendmail command?
Are you using the -f -r or -R options?

This is the code .. As mentioned we can send attachments to gmail, yahoo etc ..
But we would need to know if the email failed because of an invalid address
I tried to convert the code to use mailx but the attachments comes in as text inside the email instead of an attachment.

Any help is appreciated

#!/usr/bin/ksh

export MAILTO="<email address>"
export SUBJECT="Test mail PDF"
export ATTACH="1.pdf"
(
echo "Date: $(date)"
echo "To: $MAILTO"
echo "Subject: $SUBJECT"
echo "MIME-Version: 1.0"
echo 'Content-Type: multipart/mixed; boundary="-q1w2e3r4t5"'
echo
echo '---q1w2e3r4t5'
echo 'Content-Type: text/plain'
echo 'Content-Disposition: inline'
echo
echo "This is a  message for PDF attachment test"
echo '---q1w2e3r4t5'
echo 'Content-Type: application/pdf; name="'$(basename $ATTACH)'"'
echo "Content-Transfer-Encoding: base64"
echo 'Content-Disposition: attachment; filename="'$(basename $ATTACH)'"'
uuencode -m $ATTACH $(basename $ATTACH)
echo '---q1w2e3r4t5--'
) | /usr/sbin/sendmail $MAILTO

try adding:

echo "From: $FROM"

after the To: line.
change the last line to:

)| /usr/sbin/sendmail -f $FROM $MAILTO

Does uuencode produce the same output as b64encod ?

That worked .. now we get a notification if the email failed
Thanks again

1 Like