Sending E-mail that reaches the destination using PHP

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    2 Favorites

    Sending E-mail that reaches the destination using PHP - Presentation Transcript

    1. Sending E-mail that reaches the destination Manuel Lemos mlemos@acm.org http://www.ManuelLemos.net/ http://www.phpclasses.org/mimemessage
    2. The problems Sending e-mail is fundamental ● PHP native support for sending e-mail is ● deficient The Internet e-mail standards are complicated ● Incorrectly composed messages are ● discarded Correctly composed messages are confused ● with SPAM
    3. Solution Ready to use PHP components for sending e‑mail PHPMailer ● PEAR Mail ● SWIFT mailer ● MIME message ● Etc. ●
    4. What is MIME? Multipurpose Internet Mail Extensions ● Standards for sending E-mail messages ● Defined by many RFC documents: Request ● For Comments New RFC document versions are compatible ● with past versions
    5. MIME message class PHP class to compose and send e-mail Sends messages with text and HTML using ● any character set Embeds related files: images, CSS, etc.. ● May attach multiple files ● Optimized for sending newsletters to many ● recipients
    6. Text message require('email_message.php'); $m = new email_message_class; $m->SetEncodedHeader('Subject', 'This is the subject'); $m->SetEmailEncodedHeader('From', 'john@here.com', 'John'); $m->SetEmailEncodedHeader('To', 'joe@there.com', 'Joe'); $text = “Hello Joe,\\n\\nThis is the message.”; $m->AddQuotedPrintableTextPart($text); $m->Send();
    7. HTML message $html = “<html><head><title>Messagm</title></head><body>Hello Joe,<br />\\n<br />\\nThis is the message.</body></html>”; $text = strip_tags($html); $m->CreateQuotedPrintableHTMLPart($html, '', $h); $m->CreateQuotedPrintableTextPart($text, '', $t); $alternatives = array($t, $h); $m->AddAlternativeMultipart($alternatives); $m->Send()
    8. HTML messages with embedded images $image=array( $m->CreateQuotedPrintableHTMLPart ($html, '', $h); 'FileName'=>'image.gif', 'Content-Type' => $text = strip_tags($html); 'automatic/name', $m->CreateQuotedPrintableTextPart 'Disposition'=>'inline' ($text, '', $t); ); $alternatives = array($t, $h); $e->CreateFilePart($image, $i); $m->AddAlternativeMultipart ($alternatives); $url = 'cid:'. $related = array( $alternatives, $m->GetPartContentID($i); $i, $html = \"<html> ); <head><title>Message</title> $m->AddRelatedMultipart </head><body><img src=\\”$url\\” /> ($related); Hello Joe,<br />\\n<br />\\nThis is the message.</body></html>\"; $m->Send()
    9. Message with attached files $attachment=array( 'Data'=>'This is an attachment called attachment.txt', 'Name'=>'attachment.txt', 'Content-Type'=>'automatic/name', 'Disposition'=>'attachment', ); $m->AddFilePart($attachment); $attachment=array( 'FileName'=>'attachment.zip', 'Content-Type'=>'automatic/name', 'Disposition'=>'attachment', ); $m->AddFilePart($attachment); $m->Send();
    10. Sending via SMTP Supports several types of authentication using the SASL classes: LOGIN, MD5, NTLM, etc. require('sasl.php'); require('smtp.php'); require('smtp_message.php'); $m = new smtp_message_class; $m->smtp_host = 'smtp.gmail.com'; $m->smtp_port = 465; $m->smtp_ssl = 1; $m->smtp_user = 'some_user'; $m->smtp_password = 'some_password'; $m->direct_delivery = 0;
    11. Sending via sendmail, qmail and Microsoft Exchange Faster delivery to the MTA queue require('sendmail_message.php'); $m = new sendmail_message_class; $m->delivery_mode = SENDMAIL_DELIVERY_DEFERRED; require('qmail_message.php'); $m = new qmail_message_class; require('pickup_message.php'); $m = new pickup_message_class;
    12. Mail() function alternatives When the mail() function does not work well smtp_mail() ● sendmail_mail() ● qmail_mail() ● urgent_mail() ●
    13. The path of the messages Local SMTP Local queue Destination queue SMTP Pickup PHP script MTA Destination SMTP mail() Direct
    14. The best delivery methods 1.Drop a message file in the local queue 2.Pass to MTA with the mail function (sendmail) 3.Pass to the local SMTP server 4.Direct delivery to the destination SMTP server
    15. Optimizing the delivery of non‑personalized newsletters $list = array( 'peter@here.com'=>'Peter', 'paul@there.com'=>'Paulo', 'mary@overthere.com'=>'Mary' ); $m->SetBulkMail(1); $m->cache_body = 1; foreach($list as $email => $name) { $m->SetEncodedEmailHeader('To', $email, $name); $m->Send(); } $m->SetBulkMail(0);
    16. Optimizing the delivery of personalized newsletters $m->SetBulkMail(1); $m->cache_body = 0; $template = 'Hello {name}, ...'; $m->CreateQuotedPrintableTextPart($template, '', $part_template); $m->AddPart($part_template); foreach($list as $email => $name) { $m->SetEncodedEmailHeader('To', $email, $name); $text = str_replace('{name}', $name, $template); $m->CreateQuotedPrintableTextPart($text, '', $personalized); $m->ReplacePart($part_template, $personalized); $m->Send(); } $m->SetBulkMail(0);
    17. Handling returned messages 1.Set the Return-Path message header to an address associated with a POP3 mailbox 2.Periodically poll that mailbox using a POP3 client class 3.Process the returned messages with the MIME parser class 4.Unsubscribe from the newsletters the e‑mail addresses that are returning the messages
    18. Know when a message was received Techniques that do not always work 1.Set the Disposition-Notification-To message header to an address to which reception notices will be sent 2.Insert a beacon image in an HTML message using the URL of a script that accounts messages that are viewed by recipients <img src=”http://www.meusite.com.br/conta.php?usuario=joao@ali.com.br”>
    19. Avoid confusion with SPAM What types of messages you should not send? ● Sent from an IP address without reverse DNS record (PTR) or that is listed in blacklists ● The recipient e-mail addresses are in Bcc Only with an HTML part or has invalid HTML ● With beacon image URL that has parameters ● Link URLs do not match anchor text URL ● Do not pass SpamAssassin checks ●
    20. Questions? Manuel Lemos mlemos@acm.org http://www.phpclasses.org/mimemessage
    21. References MIME Message class ● http://www.phpclasses.org/mimemessage SMTP client class ● http://www.phpclasses.org/smtpclass SASL authentication class ● http://www.phpclasses.org/sasl POP3 client class ● http://www.phpclasses.org/pop3class MIME parser class ● http://www.phpclasses.org/mimeparser Verify IP addresses in multiple blacklists ● http://openrbl.org/ SpamAssassin ● http://spamassassin.apache.org/

    + manuellemosmanuellemos, 10 months ago

    custom

    3545 views, 2 favs, 50 embeds more stats

    Slides of a presentation about the PHP MIME message more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 3545
      • 2072 on SlideShare
      • 1473 from embeds
    • Comments 0
    • Favorites 2
    • Downloads 73
    Most viewed embeds
    • 1344 views on http://www.phpclasses.org
    • 58 views on http://www.createwebsite.info
    • 8 views on http://phpclasses.ca
    • 4 views on http://phpclasses.100pour100net.com
    • 3 views on http://phpclasses.ranchoweb.com

    more

    All embeds
    • 1344 views on http://www.phpclasses.org
    • 58 views on http://www.createwebsite.info
    • 8 views on http://phpclasses.ca
    • 4 views on http://phpclasses.100pour100net.com
    • 3 views on http://phpclasses.ranchoweb.com
    • 3 views on http://phpclasses.goodphp.com
    • 2 views on http://fonant.mirrors.phpclasses.org
    • 2 views on http://phpclasses.betablue.net
    • 2 views on http://cfgmgr.mirrors.phpclasses.org
    • 2 views on http://infinite.mirrors.phpclasses.org
    • 2 views on http://translate.googleusercontent.com
    • 2 views on http://phpclasses.nlared.com
    • 2 views on http://chimit.mirrors.phpclasses.org
    • 2 views on http://goodphp.mirrors.phpclasses.org
    • 2 views on http://phpclasses.fonant.com
    • 1 views on http://phpclasses.chimit.nl
    • 1 views on http://phpclasses.mirrors.php-homepage.de
    • 1 views on http://safe.phpclasses.net
    • 1 views on http://php-classes.redesbr.com.br
    • 1 views on http://phpclasses.controloye.com
    • 1 views on http://static.slidesharecdn.com
    • 1 views on http://ranchoweb.mirrors.phpclasses.org
    • 1 views on http://cat.mirrors.phpclasses.org
    • 1 views on http://lpt.mirrors.phpclasses.org
    • 1 views on http://studiopilot.testpilotweb.com
    • 1 views on http://phpclasses.freelancer.gs
    • 1 views on http://74.125.153.132
    • 1 views on http://evert.mirrors.phpclasses.org
    • 1 views on http://phpclasses.masbytes.es
    • 1 views on http://phpclasses.mkdata.net
    • 1 views on http://phpclasses.phpsoft.it
    • 1 views on http://phpclasses.cfappsinc.ca
    • 1 views on http://localhost
    • 1 views on http://phpclasses.sgboards.com
    • 1 views on http://phpclasses.mirror.8086.net
    • 1 views on http://sarah.phpclasses.org.icontem.com
    • 1 views on http://lixlpixel.users.phpclasses.org
    • 1 views on http://phpclasses.2by2host.com
    • 1 views on http://phpclasses.burina.net
    • 1 views on http://phpclasses.toperz.pl
    • 1 views on http://nlared.mirrors.phpclasses.org
    • 1 views on http://phpclasses.waaf.net
    • 1 views on http://phpclasses.infinitehost.com.br
    • 1 views on http://mkdata.mirrors.phpclasses.org
    • 1 views on http://phpclasses.elib.com
    • 1 views on http://elib.mirrors.phpclasses.org
    • 1 views on http://phpclasses.segmenta.ru
    • 1 views on http://as2by2host.mirrors.phpclasses.org
    • 1 views on http://b8086.mirrors.phpclasses.org
    • 1 views on http://static.slideshare.net

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories