[ZendTo] HTML Email

Gray McCord gdm at sangabriel.com
Thu Mar 9 15:25:12 GMT 2017


In my case, I have “re-skinned” An older version of Zendto and since I wanted the html emails to reflect my company branding, I edited the various email templates so that they would be multipart/mime instead of text files.  It wasn’t a huge deal, and just required a little bit of html/css knowledge to make it work.

 

 

Here’s a sample from the pickup_email.tpl :

 

--xxcompanynameherexx
Content-Type: text/plain
Pick Up Notification

A drop-off you made has been retrieved:


    Claim ID: {$claimID}
    File Name: {$filename}
    Retrieved by: {$whoWasIt}
    At Location: {if $hostname eq $remoteAddr}{$remoteAddr}{else}{$hostname} ({$remoteAddr}){/if}

--xxcompanynameherexx
Content-Type: text/html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>M3 FileShare</title>
    <style type="text/css">
        <!--
        body,td,th {
            font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
            font:12px/1.4em;
---snip---
        …the rest of the css
        }-->
    </style></head>

<body>
<img src="..link to a header image..” />

 <div id="content">
<h2>Pick Up Notification</h2>

<p>A drop-off you made has been retrieved:</p>

<ul>
    <li>Claim ID: {$claimID}</li>
    <li>File Name: {$filename}</li>
    <li>Retrieved by: {$whoWasIt}</li>
    <li>At Location: {if $hostname eq $remoteAddr}{$remoteAddr}{else}{$hostname} ({$remoteAddr}){/if}</li>
</ul>
 </div>
</body>
</html>
--xxcompanynameherexx--

 

 

Gray McCord

Adapt, Mutate, Migrate, or Die

                                                          -C. Darwin

 

From: <zendto-bounces at zend.to> on behalf of Greg Marshall <gmarsh at truman.edu>
Reply-To: ZendTo Users <zendto at zend.to>
Date: Thursday, March 9, 2017 at 7:42 AM
To: ZendTo Users <zendto at zend.to>
Subject: Re: [ZendTo] HTML Email

 

Jules,

I think PHPMailer will do what you want:

https://github.com/PHPMailer/PHPMailer/wiki/Tutorial

 

Greg

 

 

Greg Marshall

Web Services Manager

IT Services

Truman State University

111C McClain Hall

100 E. Normal Avenue

Kirksville, MO 63501

(660) 785-4254

gmarsh at truman.edu

www.truman.edu

Don’t follow.  Pursue.

 

On Mar 9, 2017, at 4:59 AM, Jules <Jules at zend.to> wrote:

 

Karl,

I've thought of one problem of your approach: you should really put in both text and HTML variants of the message to create a multipart-alternative MIME message.
However, if there are any PHP libraries out there which will do the MIME encoding for me, I can just add a template file for the HTML part of the message, and build the entire MIME message from the text part (which we already have in place) and the new HTML part. That allows for the possibility of adding an image or two within the message as well.

If anyone out there fancies a quick dig for how to create multipart MIME messages in PHP, please do let me know what you find.

Cheers,
Jules.


On 08/03/2017 18:58, Jules wrote:

Karl,

Me likes!

That's simpler than what I originally had in mind, as you specifically are not embedding the image files. It does however mean that recipients who aren't displaying remote images have to click the "fetch the images" button in their mail client, which isn't *quite* as nice.

But if people are happy to live with that as a compromise, I should be able to work this in very easily.

BTW If you haven't spotted it yet, there's a bug in the way the "you haven't picked up your drop-off and it's about to expire" reminders are generated. Currently that means the URL to reach the download page is missing the MailScanner has detected a possible fraud attempt from "your-zendto.company.com" claiming to be "https://your-zendto.company.com/" off the front of it. So the links in the reminders don't work. The original messages sent out when the drop-off is created are fine, it's just the reminders when no one has picked up that drop-off at all, and it's about to expire.

You can work around that by just hard-coding the start of the URL in dropoff_email.tpl.
You need to replace "{$zendToURL}" with something like MailScanner has detected a possible fraud attempt from "zendto.your-company.com" claiming to be "https://zendto.your-company.com/" or whatever is appropriate for you.

I'm thinking about a solution to this...

Cheers,
Jules.

On 08/03/2017 18:43, Karl Bundy wrote:

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.
 
<Mail Attachment.jpeg>
 
Thanks,
 
Karl
_______________________________________________
ZendTo mailing list
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
Twitter: @JulesFM
PGP footprint: EE81 D763 3DB0 0BFD E1DC 7222 11F6 5947 1415 B654
_______________________________________________
ZendTo mailing list
ZendTo at zend.to
http://mailman.ecs.soton.ac.uk/mailman/listinfo/zendto
Jules
 
-- 
Julian Field MEng MBCS CITP CEng
 
'There is one thing stronger than all the armies in the world;
 and that is an idea whose time has come.'
 
www.Zend.To
Twitter: @JulesFM
PGP footprint: EE81 D763 3DB0 0BFD E1DC 7222 11F6 5947 1415 B654
Jules
 
-- 
Julian Field MEng MBCS CITP CEng
 
'Adversity is like a strong wind. I don't mean just that it holds
 us back from places we might otherwise go. It also tears away from
 us all but the things that cannot be torn, so that afterward we see
 ourselves as we really are, and not merely as we might like to be.'
 - Arthur Golden
 
www.Zend.To
Twitter: @JulesFM
PGP footprint: EE81 D763 3DB0 0BFD E1DC 7222 11F6 5947 1415 B654
_______________________________________________
ZendTo mailing list
ZendTo at zend.to
http://mailman.ecs.soton.ac.uk/mailman/listinfo/zendto

 

_______________________________________________ ZendTo mailing list ZendTo at zend.to http://mailman.ecs.soton.ac.uk/mailman/listinfo/zendto

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ecs.soton.ac.uk/pipermail/zendto/attachments/20170309/6221cf82/attachment-0001.html 


More information about the ZendTo mailing list