Mailing multiple PNG attachments using sendmail


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Mailing multiple PNG attachments using sendmail
# 1  
Old 02-04-2015
Code Mailing multiple PNG attachments using sendmail

Need assistance in using the below script and having multiple png file attachments in the same script . Your inputs are appreciated. I dont have uuencode , I use either mailx, sendmail, mpack .

Code:
( echo "to: samplemail@somewhere.com"
  echo "from: samplemail@elsewhere.com"
  echo "subject: sending file.jpg"
  echo "mime-version: 1.0"
  echo "content-type: multipart/related; boundary=xxxRANDOMSTRINGxxx"
  echo
  echo "--xxxRANDOMSTRINGxxx"
  echo "content-type: text/plain"
  echo
  echo "Body of the message goes here"
  echo "Here is file.jpg for your viewing pleasure"
  echo
  echo "--xxxRANDOMSTRINGxxx"
  echo "content-type: image/gif; name=file.png"
  echo "content-transfer-encoding: base64"
  echo
  openssl base64 < file.png ) | sendmail -t -i

# 2  
Old 02-04-2015
As far as I know uuencode , mailx, sendmail and mpack are all capable of sending an email with a single attachment. You should look at the various Perl libraries to see if one works for you. I have used MIME::Lite in the past. There are scripts that you can find online with your favorite search engine. Just add logic for additional attachments.
This User Gave Thanks to gandolf989 For This Post:
# 3  
Old 02-04-2015
Code

Thank you very much gandolf989. It worked .

I installed the perl module "MIME-Lite-3.01.tar.gz" used the below code and it works great.

Code:
#!/usr/bin/perl

use MIME::Lite;

$from = 'qwerty\@erweer.com';
$to = 'abcd\@efgh.com';
$Subject = 'Hello';

# Part using which the attachment is sent to an email #
$msg = MIME::Lite->new(
        From     => $from,
        To       => $to,
        Subject  => $Subject,
        Type     => 'multipart/Mixed',
);
$msg->attach(
      Type     => 'Text', 
      Data     => "The attachment contains your file"
);
$msg->attach(
    Type     => 'Image/gif',
        Path         => "/abcd/M.gif"
);

print "Mail Sent\n";
$msg->send; # send via default

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sendmail - Attachments & Subjects

Hi All, Not been around in a while. However I have been all over tinternet (google) for days looking for a solution. Where I work has decided to use Sendmail on our Linux and Unix estate for sending emails via scripts. So I am hoping to eventually get a working solution for Sendmail and not... (3 Replies)
Discussion started by: dakelly
3 Replies

2. Shell Programming and Scripting

Sendmail gz Attachments

Hi All, I have a problem again with sendmail content type . I am trying to attach the gz file to the html email but couldnt figure out even after extensive google. Here is my code. ( echo "From: $FROM" echo "To: $MAILTO" echo... (3 Replies)
Discussion started by: posner
3 Replies

3. Shell Programming and Scripting

Sendmail Png Attachments

I use sendmail to send html emails, my script works perfect and sends email with plain text attachment. Now i need to attache png file to the email and this attachment part is not working. ( echo "From: $FROM" echo "To: $TO" echo "MIME-Version: 1.0" echo "Subject: $SUBJECT" echo... (4 Replies)
Discussion started by: posner
4 Replies

4. Shell Programming and Scripting

Sendmail Script: Gmail cannot find attachments

Hi. I am using a script on HP-UX to send emails that include a Pdf attachment to clients. The scipt makes use of sendmail. The scripts works for everything except gmail. When I go on gmail via my Web Browser, I can see the message with the attachment, but if I try to view or download the... (2 Replies)
Discussion started by: Wahooka
2 Replies

5. Shell Programming and Scripting

E-mailing Multiple Attachments in AIX

Hello Everyone, I'm trying to write ascript on AIX 5.3, that will e-mail all filles within a directory. But on executing a script , it sends only 1 file from the directory alongwith some Junk data. I have searched whole forum and almost used all the suggestions, but still getting same problem.... (4 Replies)
Discussion started by: Gem_In_I
4 Replies

6. Shell Programming and Scripting

sendmail with attachments

Hi, I got the following script from Ygor on this site: #!/usr/bin/ksh export MAILTO="email_address" export CONTENT="/export/home/aisdba/email_body.html" export SUBJECT="subject of email" ( echo "Subject: $SUBJECT" echo "MIME-Version: 1.0" echo "Content-Type: text/html" echo... (9 Replies)
Discussion started by: suthera
9 Replies

7. UNIX for Dummies Questions & Answers

sendmail attachments

Dear all, I've been working with AIX for, um, 15 years now and I have read all I can about the above, but I am stuck. Everything seems to point to using sendmail on the command line to embed a uuencoded attatchment will not work. Using something like "(cat plain.txt;uuencode attach.file... (4 Replies)
Discussion started by: rbatte1
4 Replies

8. UNIX for Advanced & Expert Users

mailing with attachments in mail command in HP-UX Release 11i

Hi Can some one tell me how to send a mail with body and file attached in a shell sript, in HP-UX Release 11i. i did code in AIX and it works fine but i guess here in HP-UX release.. there's some syntax change which i;m not able to make out.. TIA, Ronnie (1 Reply)
Discussion started by: rosh0623
1 Replies

9. Answers to Frequently Asked Questions

multiple attachments

how can you send multiple attachments in 1 email, usually I just use uuencode to send 1 attachment. thanks (5 Replies)
Discussion started by: edog
5 Replies

10. How do I send email?

multiple attachments

how can you send multiple attachments in 1 email, usually I just use uuencode to send 1 attachment. thanks (5 Replies)
Discussion started by: edog
5 Replies
Login or Register to Ask a Question