WorxWare

Andy's Blog
  • Home
  • Contact
  • Log in

Welcome to my blog!

Through this blog, I will be posting articles on technology, mainly related to email processing.

Please keep your replies related to the topic. This blog will not be used to provide any support or individual tutorials.

  • By Andy Prevost
  • August 21st, 2009
  • Posted in Welcome
  • 16488 views
  English (US) latin1  
 

Hotmail Server Changes

Microsoft has recently made changes to their Hotmail ports and settings.

Our basic example on the PHPMailer website now is:

require_once('../class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded

$mail = new PHPMailer();

$body = file_get_contents('contents.html');
$body = eregi_replace("[\]",'',$body);

$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "mail.yourdomain.com"; // SMTP server
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "tls"; // sets the prefix to the servier
$mail->Host = "smtp.live.com"; // sets HOTMAIL as the SMTP server
$mail->Port = 25; // alternate is "26" - set the SMTP port for the HOTMAIL server
$mail->Username = "yourusername@hotmail.com"; // HOTMAIL username
$mail->Password = "yourpassword"; // HOTMAIL password

$mail->SetFrom('name@yourdomain.com', 'First Last');

$mail->AddReplyTo("name@yourdomain.com","First Last");

$mail->Subject = "PHPMailer Test Subject via smtp (Hotmail), basic";

$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test

$mail->MsgHTML($body);

$address = "whoto@otherdomain.com";
$mail->AddAddress($address, "John Doe");

$mail->AddAttachment("images/phpmailer.gif"); // attachment
$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment

if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}

Andy

  • By Andy Prevost
  • May 31st, 2010
  • Posted in Mail Servers
  • 143 views
  • Send feedback »
  English (US) latin1  
 

Stripping HTML code for AltBody and PHPMailer-FE

As the developers, we obviously use PHPMailer extensively in our applications. In some, we were using HTML2Text, a very good utility available at chuggnut.com. For basic forms processing, HTML2Text is overkill and does not render the forms data properly -- particularly the tables, th, td, and tr tags.

We modified several functions that we use in our content management systems and in our own PHPMailer scripts and wish to discuss those here and provide them for your use: same license as PHPMailer, LGPL -- please attribute properly.

The two functions that we modified are:

  1. A function that strips out the <body> tag through to the </body> tag, inclusive. We use this in a commercial email marketing application to strip out all the HTML tags above and including <body ... > and strip out all the HTML tags below and including </body> (meaning exclusive of the body tags) ... the modifications are to inverse the results returning only the inclusive portion.
  2. A function that:
    • converts HTML entities to character representations
    • strips out all new line characters and spaces after the closing tag element
    • converts </td></tr> to new line characters
    • converts </td> to a colon and space
    • then strips all tags

The first function is to strip out certain code that is not processed by other HTML to Text conversion utilities. One example, is the <style></style> tags and everything contained within those two tags.

function _stripStartEndStr($str,$startTag='<style>',$endTag='</style>') {
/* Copyright Andy Prevost */
$startTag = strtolower($startTag);
$endTag = strtolower($endTag);
$lower_contents = strtolower($str);
// determine if a $startTag tag exists and process if necessary
do { $posStart = strpos($lower_contents,$startTag);
if ( $posStart !== false ) {
$posEndStart = strpos($lower_contents, $endTag);
$posEnd = $posEndStart + strlen($endTag) + 1;
$posEnd = $posEnd - $posStart;
// return stripped out tags and contents
$strPart = substr($str, $posStart, $posEnd);
$str = str_replace($strPart,'',$str);
}
} while (0);
return $str;
}

To use this function, derive your HTML the normal way, then convert it to text:

$html = {whatever you normally do};

$text = _stripStartEndStr($html);

The next function does the actual HTML to Text conversion. Note that it will render your tables reasonably, convert all HTML entities to characters (like &copy; to ©)

function _html2txt($html) {
/* Copyright Andy Prevost */
if (trim($html)=='') { return $html; }
$text = htmlspecialchars_decode($html);
$text = str_replace("</table>", "</TABLE>", $text);
do { if (strpos($text," </TABLE>")) { $text = str_replace(" </TABLE>", "</TABLE>", $text); } else { break; } } while (0);
do { if (strpos($text,">\n\n")) { $text = str_replace(">\n\n", ">\n", $text); } else { break; } } while (0);
$text = str_replace(">\n", ">", $text);
$text = str_replace("</tr>", "</TR>", $text);
$text = str_replace("</td>", "</TD>", $text);
$text = str_replace("</th>", "</TH>", $text);
$text = str_replace("</TD></TR>", "\n", $text);
$text = str_replace("</TH></TR>", "\n", $text);
$text = str_replace("</TD>", ": ", $text);
$text = str_replace("</TH>", ": ", $text);
$text = str_replace("</TR>", "\n", $text);
$text = strip_tags($text);
return $text;
}

... then add your HTML content, and add your Text content

$mail->MsgHTML($html);

$mail->AltBody = _html2txt($text);

Enjoy!
Andy

  • By Andy Prevost
  • May 31st, 2010
  • Posted in Welcome, Extending PHPMailer
  • 263 views
  • Send feedback »
  English (US) latin1  
 

New Documentation Site coming!

We are working on new documentation for all of our software. The documentation will include:

  • Requirements
  • Pre-installation instructions
  • Installation instructions
  • Accessing the installed software
  • Basic usage and tutorials

The first set of documentation is nearly complete for our upcoming release of PHPMailer-ML version 1.8.

The documentation is being setup as a "knowledgebase" and you can preview it at:

http://www.worxware.com/kb/

[update: feb 04 2010] The documentation site software is not flexible enough to provide an organized view of the documentation the way we want it. We are working on another software platform at:

http://www.worxware.com/kbn/

Enjoy!
Andy

 

 

  • By Andy Prevost
  • November 26th, 2009
  • Posted in Welcome
  • 398 views
  English (US) latin1  
 

Significant new enhancements for PHPMailer-ML

PHPMailer-ML v1.8 will include some significant new features including an enhanced user interface, plus:

  • Accordion for left column and right column of page design
  • More help for Campaigns page
  • Tooltips to display more Subscriber information
  • Username/Password editor for .HTPASSWD file -- allows for multiple users (with only one full admin)
  • Integrated QuickCSV
  • New "modules" structure for future expansion of features
  • Ability to track the opening of emails
  • with basic statistics page showing who/when email was opened
  • ... and lots more

It's clear that PHPMailer-ML is in the mainstream of Mailing List managers and Email campaign management. PHPMailer-ML is approaching 50,000 users and with the upcoming new features, PHPMailer-ML is expected to become the most popular mailing list software available.

Andy

  • By Andy Prevost
  • November 1st, 2009
  • Posted in Welcome
  • 471 views
  English (US) latin1  
 
1 2 3 >>
  • WorxWare

  • My thoughts on technology ...
    • Recently
    • Archives
    • Categories
    • Latest comments
  • Search

  • Categories

    • All
    • Background
    • Email Related
    • Extending PHPMailer
    • Javascript
    • Mail Servers
    • News
    • Sports
    • Welcome
  • XML Feeds

    • RSS 2.0: Posts, Comments
    • Atom: Posts, Comments
    What is RSS?
  • Contents

    • Hotmail Server Changes
    • Stripping HTML code for AltBody and PHPMailer-FE
    • New Documentation Site coming!
    • Significant new enhancements for PHPMailer-ML
    • Create DKIM public/private keys
    • DKIM and Callback function for PHPMailer
    • PHPMailer Lite
    • Gmail Server Changes ...
    • Welcome to my blog!
    • A bit about me ...
    • Martial Arts
  • Google Ads


Powered by b2evolution