Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h2>Send a Plaintext body email with one plaintext attachment with mailx:</h2> <pre><code>( /usr/bin/uuencode attachfile.txt myattachedfilename.txt; /usr/bin/echo "Body of text" ) | mailx -s 'Subject' youremail@gmail.com </code></pre> <p>Below is the same command as above, without the newlines</p> <pre><code>( /usr/bin/uuencode /home/el/attachfile.txt myattachedfilename.txt; /usr/bin/echo "Body of text" ) | mailx -s 'Subject' youremail@gmail.com </code></pre> <p>Make sure you have a file <code>/home/el/attachfile.txt</code> defined with this contents:</p> <pre><code>&lt;html&gt;&lt;body&gt; Government discriminates against programmers with cruel/unusual 35 year prison sentences for making the world's information free, while bankers that pilfer trillions in citizens assets through systematic inflation get the nod and walk free among us. &lt;/body&gt;&lt;/html&gt; </code></pre> <p>If you don't have uuencode read this: <a href="https://unix.stackexchange.com/questions/16277/how-do-i-get-uuencode-to-work">https://unix.stackexchange.com/questions/16277/how-do-i-get-uuencode-to-work</a></p> <h2>On Linux, Send HTML body email with a PDF attachment with sendmail:</h2> <p>Make sure you have ksh installed: <code>yum info ksh</code></p> <p>Make sure you have sendmail installed and configured.</p> <p>Make sure you have uuencode installed and available: <a href="https://unix.stackexchange.com/questions/16277/how-do-i-get-uuencode-to-work">https://unix.stackexchange.com/questions/16277/how-do-i-get-uuencode-to-work</a></p> <p>Make a new file called <code>test.sh</code> and put it in your home directory: <code>/home/el</code></p> <p>Put the following code in <code>test.sh</code>:</p> <pre><code>#!/usr/bin/ksh export MAILFROM="el@defiant.com" export MAILTO="youremail@gmail.com" export SUBJECT="Test PDF for Email" export BODY="/home/el/email_body.htm" export ATTACH="/home/el/pdf-test.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 $ATTACH $(basename $ATTACH) echo "--$MAILPART--" ) | /usr/sbin/sendmail $MAILTO </code></pre> <p>Change the export variables on the top of <code>test.sh</code> to reflect your address and filenames.</p> <p>Download a test pdf document and put it in <code>/home/el</code> called pdf-test.pdf</p> <p>Make a file called /home/el/email_body.htm and put this line in it:</p> <pre><code>&lt;html&gt;&lt;body&gt;&lt;b&gt;this is some bold text&lt;/b&gt;&lt;/body&gt;&lt;/html&gt; </code></pre> <p>Make sure the pdf file has sufficient 755 permissions.</p> <p>Run the script <code>./test.sh</code></p> <p>Check your email inbox, the text should be in HTML format and the pdf file automatically interpreted as a binary file. Take care not to use this function more than say 15 times in a day, even if you send the emails to yourself, spam filters in gmail can blacklist a domain spewing emails without giving you an option to let them through. And you'll find this no longer works, or it only lets through the attachment, or the email doesn't come through at all. If you have to do a lot of testing on this, spread them out over days or you'll be labelled a spammer and this function won't work any more.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload