Forum OpenACS Development: Sending email within attachements

Request notifications

Collapse
Posted by Iuri Sampaio on
Sending emails within attachments is very easy and straightforward, using ad_proc [acs_mail_lite::send]

However, how would those attachments be referenced within the body of the email itself (i.e. as part of the HTML content?

I'd like to use those attachments (i.e. images) within the body of the email itself. How would I call files? What should  I write within img HTML tags.

For example in node.js it would be something like:

var params = {
  smtpapi:  new mail.SmtpapiHeaders(),
  ... //some vars removed here!
  files: [
    {
      filename:    'image.jpg',
      contentType:  'image/jpeg',
      cid:          'myimagecid',
      content:      ('yourbase64encodedimageasastringcangohere' | Buffer)
    }
  ],
  file_data:  {},
  headers:    {}
};

and the HTML is

<html>
  <body>
    <img src="cid:myimagecid"/>
  </body>
</html>

Collapse
Posted by Iuri Sampaio on
The HTML is
< html >
  < body >
    < img src="cid:myimagecid" />
  < /body >
< /html >

The scenario on OACS is

...
set body "[_ evex-event.event-request-notification]"
acs_mail_lite::send -send_immediately \
    -to_addr $email_to \
    -from_addr $email_from \
    -subject "EvEx" \
    -file_ids "97651 97653" \
    -body $body \
    -mime_type "text/html"

...

Collapse
Posted by Iuri Sampaio on
ANSWER:
They are sourced by their filenames.

Switching acs-mail-lite parameter to "log" mode shows that.

[acs_mail_lite::send] written to logs points to the name of the files

MIME-Version: 1.0
Content-Disposition: attachment; filename="notificacao_marca.png"
Content-Description: notificacao_marca.png
Content-ID: < 455.1541977750.32 @ evex.co >
Content-Type: image/png;
name="notificacao_marca.png"
Content-Transfer-Encoding: base64

Collapse
Posted by Iuri Sampaio on
So far,

The answer is negative. Images are still not loaded within the HTML body

Collapse
Posted by Iuri Sampaio on
... and adding base64 in their src's would double email's size.

Reference: https://www.base64encode.org/