Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8300791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T16:41:14+00:00 2026-06-08T16:41:14+00:00

Objective: To send mail (using sendmail) with HTML body and binary attachment. Followed the

  • 0

Objective: To send mail (using sendmail) with HTML body and binary attachment.

Followed the guidelines specified in the following links

http://www.unix.com/shell-programming-scripting/159522-sendmail-html-body-attachment-2.html

http://www.unix.com/shell-programming-scripting/58448-sendmail-attachment.html

It is working to the extent that, either HTML body or the binary attachment with uuencode, but not both.

Given below is a snippet of the shell script to sendmail. With this, the HTML body is coming fine, but the attachment is getting encoded/decoded wrongly and unable to view the same.

Please advise.

#!/usr/bin/ksh

export MAILFROM="noreply@site.dom"
export MAILTO="somebody@somesite.com"
export SUBJECT="Test PDF for Email"
export BODY="email_body.htm"
export ATTACH="file.pdf"
export MAILPART=`uuidgen` ## Generates Unique ID
(
 echo "From: $MAILFROM"
 echo "To: $MAILTO"
 echo "Subject: $SUBJECT"
 echo "MIME-Version: 1.0"
 echo "Content-Type: multipart/mixed; boundary=\"-$MAILPART\""
 echo "---$MAILPART"
 echo "Content-Type: text/html"
 echo "Content-Disposition: inline"
 cat $BODY
 echo "---$MAILPART"
 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 "---$MAILPART--"
) | /usr/sbin/sendmail $MAILTO

I am using HP-UX ia64.
Have searched through the forum and web and found references mostly to PHP, Python, etc.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T16:41:15+00:00Added an answer on June 8, 2026 at 4:41 pm

    Changing the Content transfer encoding type within the email from base64 to uuencode resolved the issue.
    Thanks for the inputs so far.

    Given below is the revised script that works.

    #!/usr/bin/ksh
    
    export MAILFROM="noreply@domain.com"
    export MAILTO="mail.to@gmail.com"
    export SUBJECT="Test PDF for Email"
    export BODY="email_body.htm"
    export ATTACH="file.pdf"
    export MAILPART=`uuidgen` ## Generates Unique ID
    export MAILPART_BODY=`uuidgen` ## Generates Unique ID
    
    (
     echo "From: $MAILFROM"
     echo "To: $MAILTO"
     echo "Subject: $SUBJECT"
     echo "MIME-Version: 1.0"
     echo "Content-Type: multipart/mixed; boundary=\"$MAILPART\""
     echo ""
     echo "--$MAILPART"
     echo "Content-Type: multipart/alternative; boundary=\"$MAILPART_BODY\""
     echo ""
     echo "--$MAILPART_BODY"
     echo "Content-Type: text/plain; charset=ISO-8859-1"
     echo "You need to enable HTML option for email"
     echo "--$MAILPART_BODY"
     echo "Content-Type: text/html; charset=ISO-8859-1"
     echo "Content-Disposition: inline"
     cat $BODY
     echo "--$MAILPART_BODY--"
    
     echo "--$MAILPART"
     echo 'Content-Type: application/pdf; name="'$(basename $ATTACH)'"'
     echo "Content-Transfer-Encoding: uuencode"
     echo 'Content-Disposition: attachment; filename="'$(basename $ATTACH)'"'
     echo ""
     #uuencode -m $ATTACH $(basename $ATTACH)
     uuencode $ATTACH $(basename $ATTACH)
     echo "--$MAILPART--"
    ) > email_`date '+%Y%m%d_%H%M%S'`.out
    | /usr/sbin/sendmail $MAILTO
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to send a HTTP request to a web service using Objective-C ? I
The objective is to send data over an HTTP Post with JSON in it.
Ideally, I would like to send an HTTP Request using POST to the Push
Objective: I want to send multiple images using multipart/form-data. Below is a snippet of
Possible Duplicate: how can send a file as attachment in objective c I want
I would like to send a simple HTTP to a web server in Objective-C.
Using Objective-C, how can I give/take the permissions for all user to read a
In objective-c whats the difference between using a . and using ->? I've used
Is it possible to have an objective-c application send and receive iChat messages without
I try to send an image with the help of shareKit without using an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.