The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > OS Specific Forums > AIX
Google UNIX.COM


AIX AIX is IBM's industry-leading UNIX operating system that meets the demands of applications that businesses rely upon in today's marketplace.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to send an email with some body content and attachment balireddy_77 Shell Programming and Scripting 2 1 Week Ago 03:33 AM
Script needed which will send a mail with attachment files Mar1006 Shell Programming and Scripting 4 11-24-2007 04:59 AM
AIX send mail with HTML message body and a binary attachment G-Man UNIX for Dummies Questions & Answers 4 03-22-2007 10:15 AM
Send an attachment and html text both in the same mail stefan.yu Shell Programming and Scripting 4 10-26-2006 06:46 PM
Send Mail with attachment and a body manojram How do I send email? 4 04-26-2004 08:53 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-22-2007
Registered User
 

Join Date: Mar 2007
Posts: 5
Command line/Script to send E-mail with HTML body and binary attachment

I apoligize for the cross-post but I'm not getting much in the way of help in the dummies forum:

I'm trying to script sending an e-mail message on an AIX 5.x server with the following requirements:
1. command line switch to specify file name containing message body in HTML format
2. command line switch to specify file name of a binary attachment
3. command line or input file to specify recipients (both to:, cc: and bcc
4. command line to specify From: address
5. command line to specify mail subject (subject text may include spaces)

I've tried every combination redirecting and piping uuencode and mail/mailx you could ever come up with with no luck.

The stumbling block is the HTML message body. Attaching a binary file to a text message body is a no brainer but I have to have the message body in HTML because we are using formatted tables.

Any help would be greatly appreciated.

Thanks.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 03-22-2007
Ygor's Avatar
Moderator
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,223
This works on a linux box which has uuencode --base64 so you may have to modify for AIX.
Code:
#!/usr/bin/ksh

export MAILTO="spam@ebay.com"
export SUBJECT="Report"
export BODY="/tmp/report.html"
export ATTACH="/tmp/sample.pdf"
(
 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/html"
 echo "Content-Disposition: inline"
 cat $BODY
 echo '---q1w2e3r4t5'
 echo 'Content-Type: application; name="'$(basename $ATTACH)'"'
 echo "Content-Transfer-Encoding: base64"
 echo 'Content-Disposition: attachment; filename="'$(basename $ATTACH)'"'
 uuencode --base64 $ATTACH $(basename $ATTACH)
 echo '---q1w2e3r4t5--'
) | /usr/sbin/sendmail $MAILTO
Reply With Quote
  #3 (permalink)  
Old 03-23-2007
Registered User
 

Join Date: Mar 2007
Posts: 5
Thanks. Tested with it after modifying for AIX uuencode syntax. Didn't work but we are really close.

This particular html document is actually a "Save As" from a Microsoft Word document and it appears that Microsoft puts some additional HTML kung-fu in the header that that doesn't fully comply with the RFC.

Any chance you can give me the correct mime syntax to use a Microsoft Word document for the message body instead of the HTML?

BTW, the correct AIX uuencode syntax for base 64 is:
uuencode -m input_file output_file
Reply With Quote
  #4 (permalink)  
Old 04-18-2007
Registered User
 

Join Date: Apr 2007
Posts: 3
Try if the below works for u......

##################################

TIMESTAMP=`date +"%m-%d"`
mailx -s "$TIMESTAMP - Hi" abc@att.com << EOF
`/usr/bin/uuencode /tmp/Test.pdf Test.pdf`
Hi,

See if u able to catch file....

EOF

##################################\

Cheers
ArB
Reply With Quote
Google UNIX.COM
Reply

Tags
mailx, mailx attachment

Thread Tools
Display Modes




All times are GMT -7. The time now is 08:26 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0