The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Operating Systems > 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 08-20-2008 06:33 AM
Script needed which will send a mail with attachment files Mar1006 Shell Programming and Scripting 4 11-24-2007 08:59 AM
AIX send mail with HTML message body and a binary attachment G-Man UNIX for Dummies Questions & Answers 4 03-22-2007 02:15 PM
Send an attachment and html text both in the same mail stefan.yu Shell Programming and Scripting 4 10-26-2006 09:46 PM
Send Mail with attachment and a body manojram How do I send email? 4 04-26-2004 11:53 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-22-2007
G-Man G-Man is offline
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.
  #2 (permalink)  
Old 03-22-2007
Ygor's Avatar
Ygor Ygor is offline Forum Staff  
Moderator
  
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,407
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
  #3 (permalink)  
Old 03-23-2007
G-Man G-Man is offline
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
  #4 (permalink)  
Old 04-18-2007
maestrohero maestrohero is offline
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
Sponsored Links
Closed Thread

Bookmarks

Tags
mailx, mailx attachment

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:09 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0