- Issue created by @joseph.olstad
- Status changed to Postponed: needs info
4 months ago 10:20pm 28 August 2024 - 🇦🇺Australia imclean Tasmania
This is already possible.
Including an image or other file reference within the HTML or template file, which can either be a path to the image or base64 encoded data within the
<img>
tag, will result in the image being embedded and referenced by the cid.I'll leave this open, let me know if you have a different scenario in mind.
- 🇨🇦Canada joseph.olstad
╭─◀ ☕ j olstad ▶ ~/drupal.org/phpmailer_smtp ▶ 📂4 📃12 🔗0 ▶ 🔀 2.2.x ▶
╰❯ $ grep cid * -iR
README.md: prevent you from accidentally sending out e-mails to real users from aHello @imclean,
I grepped the entire codebase of phpmailer_smtp , no documentation on cid, no code mentioning cid and I didn't find any documentation on this subject relating to the phpmailer_smtp module. - Status changed to Active
4 months ago 9:59pm 29 August 2024 - 🇦🇺Australia imclean Tasmania
@joseph.olstad phpmailer_smtp uses the PHPMailer library as much as possible rather than duplicating its functions. For example, you won't find a single preg_match in the module either, and all address parsing is done by the library.
To understand how the module works it helps to have some knowledge of the PHPMailer library.
Specifically, in the
format()
method ofDrupal\phpmailer_smtp\Plugin\Mail\PhpMailerSmtp
there is the following line:$this->msgHTML($rendered, DRUPAL_ROOT, TRUE);
This sends the message HTML to the PHPMailer library for processing, including inline attachments. So rather than a bunch of if/then/else statement and calling the inline attachment functions directly, this leaves it up to PHPMailer to determine, including generating a cid.
Have a look at
/vendor/phpmailer/phpmailer/src/PHPMailer.php
for more information.I've changed this to a task so if the documentation is lacking in this area I'm happy to accept an MR.
- 🇨🇦Canada joseph.olstad
I'll be digging more into this tomorrow and run some more indepth tests.
I scoured d.o for related documentation, it is very light.
I've dug a bit more into the PHPMailer library and it is starting to possibly make sense.
I'll try a few things soon and see how it goes.
- 🇨🇦Canada joseph.olstad
Ok wow, the phpmailer library makes this too easy. Simply include an
<img src="data:base64:xyz">
element, it's auto converted to a file attachment and the src= value changes tocid:phpmailer-0something
automatically. something that Outlook can consume.Magic happening here!
Would be great to have a bit of background with this along with some simple documentation.