I am using the below listed code, which sends PDF attachment properly.

Attachment can be opened in desktop computer and Samsung mobile but same attachment cannot be opened in IPHONE IOS.

Below is my code.

export MAILFROM="ashish.talreja@yahoo.com"
export MAILTO="sunil.rao@gmail.com"
export SUBJECT="New Report"
export BODY="/app/bo_report_schedule.html"
export ATTACH="/app/report.pdf"
export MAILPART="$RANDOM" ## Generates Unique ID
export MAILPART_BODY="$RANDOM" ## 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--"
) | /usr/sbin/sendmail $MAILTO

I also used mailx command

(echo "hi" , uuencode report.pdf report.pdf) | mailx -s "Attached is the report" "ashish.talreja@yahoo.com" 

Above command is working fine but still blank attachment on IOS and correct attachment on desktop computer.

  • As a wild guess, iOS may not support uuencode method. base64 is the usual way to encode binary attachments. – sendmoreinfo Jul 8 '15 at 20:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.