5.7.x - Send Mail attachment / Zend Mailer Class -> setType
In Concrete5.6.x we could use the Zend Mailer Class and had access to setType. Add Attachement, etc.. It was possible to set Mime type and trough this to add an attachment to a mail that existed as a string.
I don't need or want to create a file object to add an attachment. I just want to create one from the raw data. Is that not possible anymore in 5.7?
Methods in 5.6 ->http://docs.mnkras.com/class_zend___mail.html...
Methods in 5.7 ->https://concrete5.org/api/class-Concrete.Core.Mail.Service.html...
Basically, just ignore the implementation of concrete5 and use directly Zend Mailer.
At the top of your block/single page, set the following use statements:
Then where you want to send the message:
$message = new Message(); $message->addTo('[email protected]'); $message->addFrom('[email protected]'); $message->setSubject('YourTitle'); // HTML part $htmlPart = new MimePart($html); $htmlPart->encoding = Mime::ENCODING_QUOTEDPRINTABLE; $htmlPart->type = "text/html; charset=UTF-8"; // Plain text part $textPart = new MimePart($text); $textPart->encoding = Mime::ENCODING_QUOTEDPRINTABLE; $textPart->type = "text/plain; charset=UTF-8"; $body = new MimeMessage(); // With attachments, we need a multipart/related email. $content = new MimeMessage();
This works out of the box if you give a correct mail address and correct attachment. Needs still some fine tuning, but overall it does the job.
Also, I just found this:
It was probably non existent at the time you wrote you post.