[ZendTo] HTML Email

Karl Bundy karl.bundy at aldentorch.com
Wed Mar 8 18:43:08 GMT 2017


Jules,

All I did was create the new email template, added a new function to the NSSDropbox.php file (see below) based on the existing deliverEmail function, then changed the NSSDropoff.php file to use the new function and new template.  I did not embed/attach the image files, just set the URL in the HTML template.  There are more sophisticated ways to send HTML email, but the Mail function has the basics to get the job done.


/*!
   @function deliverEmailHTML

   Send the $content of in an HTML formatted email message to (one or more) address(es) in $toAddr.
*/
public function deliverEmailHTML(
   $toAddr,
   $fromAddr,
   $subject,
   $content,
   $headers = ""
)
{
// If it contains any characters outside 0x00-0x7f, then encode it
if (preg_match('/[^\x00-\x7f]/', $subject)) {
   $subject = "=?UTF-8?B?".base64_encode(html_entity_decode($subject))."?=";
}
if (preg_match('/[^\x00-\x7f]/', $fromAddr)) {
   $fromAddr = "=?UTF-8?B?".base64_encode(html_entity_decode($fromAddr))."?=";
}
if (preg_match('/[^\x00-\x7f]/', $this->_emailSenderAddr)) {
   $sender = "=?UTF-8?B?".base64_encode(html_entity_decode($this->_emailSenderAddr))."?=";
} else {
   $sender = $this->_emailSenderAddr;
}

// Add the From: and Reply-To: headers if they have been supplied.
if ($fromAddr!="") {
   $headers = sprintf("From: %s", $sender) . PHP_EOL .
      sprintf("Reply-to: %s", $fromAddr) . PHP_EOL .
      $headers;
}

// Add the MIME headers for 8-bit UTF-8 encoding
$headers .= "MIME-Version: 1.0".PHP_EOL;
$headers .= "Content-type: text/html; charset=iso-8859-1".PHP_EOL;
$headers .= "Content-Transfer-Encoding: 8bit".PHP_EOL;

return mail(
   $toAddr,
   $subject,
   $content,
   $headers // JKF Commented out for now due to security concerns ,
   // JKF Commented out for now due to security concerns
    // '-f "'.$fromAddr.'"'
    );
}


--- Karl

From: zendto-bounces at zend.to [mailto:zendto-bounces at zend.to] On Behalf Of Jules
Sent: Wednesday, March 08, 2017 11:19 AM
To: ZendTo Users <zendto at zend.to>
Subject: Re: [ZendTo] Use different AD attribute

Karl,

Yes, I agree this would be nice. I basically haven't had time to sort it all out. As I need to make the message a multipart MIME structure, the email templates get a *lot* more complicated.

What did you have to change except for any templates/*.tpl files?
Any changes you make to the *.tpl files will not be overwritten when you upgrade later.

So any hints you've got as to what I need to change in order to support the massively more complex MIME messages, please do let me know.

Thanks!
Jules.

On 22/02/2017 16:58, Karl Bundy wrote:

Jules,



Thanks for all of your ongoing work on ZendTo, it has been a huge benefit for our team, and to the whole user community!



A feature request that I would love to see is the option for HTML formatted email notices.  They give a bit of polish to the system and oddly enough seem to give our users a bit more confidence in the system.  I have hacked our instance to send HTML formatted emails (see screenshot below) and I while what I have works fine, it would be great if this type of functionality was built-in to the system so that I don't have to add back this functionality anytime we do upgrades.



[cid:image001.jpg at 01D29800.1A50F1A0]



Thanks,



Karl

_______________________________________________

ZendTo mailing list

ZendTo at zend.to<mailto:ZendTo at zend.to>

http://mailman.ecs.soton.ac.uk/mailman/listinfo/zendto

Jules



--

Julian Field MEng MBCS CITP CEng



'Once is happenstance, twice is coincidence, three times is enemy

 action.' - Ian Fleming



www.Zend.To<http://www.Zend.To>

Twitter: @JulesFM

PGP footprint: EE81 D763 3DB0 0BFD E1DC 7222 11F6 5947 1415 B654
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ecs.soton.ac.uk/pipermail/zendto/attachments/20170308/4c276128/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/jpeg
Size: 26857 bytes
Desc: image001.jpg
Url : http://mailman.ecs.soton.ac.uk/pipermail/zendto/attachments/20170308/4c276128/attachment-0001.jpg 


More information about the ZendTo mailing list