Pivotal Knowledge Base

Follow

HowTo - Use sendmail to send email notifications with attachments on DCA ?

Question

How could we use sendmail on a DCA v1/v2 to send an email with an attachment ?

Prerequisite

sendmail must be configured on DCA.

Solution

One could use MIME to send emails with attachment on a DCA v1/v2. Below is the template which one could modify according to their needs and use. You may run the below directly from the command line, just copy and paste. However, it may take some time before the control is returned, so please be patient.

Note: Replace the italic keywords with appropriate values.

( echo "to: recipient@address.com
  echo "subject: subject_of_email"
  echo "mime-version: 1.0"
  echo "content-type: multipart/related; boundary=xBoundaryStringx"
  echo
  echo "--xBoundaryStringx"
  echo "content-type: text/plain"
  echo "Email Text Body"
  echo "Email Text Body"
  echo "--xBoundaryStringx"
  echo "content-type: text/plain; charset=us-ascii; name=attachment_filename"
  echo "content-transfer-encoding: base64"
  echo
  openssl base64 < attachment_filename ) |sendmail -t -i 

Comments

Powered by Zendesk