SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Zealot
    Join Date
    May 2001
    Posts
    193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PEAR:Mail, mail(), phpmailer...

    I have a newsletter system that i was using phpmailer to send, and it's to the point now where I can't take phpmailer's flakyness anymore. It's a real crap shoot as to which silly errors are going to choke it.
    I had an issue with it yesterday where I reverted to using php's mail(). I know i was told before that using mail() was a no no, but it sent my 900 email no problem and in about half the time phpmailer was taking.

    php.net suggests using PEAR:mail for sending out bulk mail but doesnt say why. I don't want to have to cross my fingers everytime I need to send out newsletters.

    My question is what do you use to send out mail?

    Thanks for any input

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    16,426
    Mentioned
    160 Post(s)
    Tagged
    1 Thread(s)

    email

    Quote Originally Posted by MikeShank
    was told before that using mail() was a no no
    Why not?? As long as your host isn't in safe mode you can use set_time_limit() and mail(). I have sent over 2000 emails this way on occasion. But as it runs for approx 1/2 hour, not very often.

  3. #3
    SitePoint Addict
    Join Date
    Apr 2002
    Posts
    330
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by MikeShank
    I have a newsletter system that i was using phpmailer to send, and it's to the point now where I can't take phpmailer's flakyness anymore. It's a real crap shoot as to which silly errors are going to choke it.
    I had an issue with it yesterday where I reverted to using php's mail(). I know i was told before that using mail() was a no no, but it sent my 900 email no problem and in about half the time phpmailer was taking.

    php.net suggests using PEAR:mail for sending out bulk mail but doesnt say why. I don't want to have to cross my fingers everytime I need to send out newsletters.

    My question is what do you use to send out mail?
    mail() may be ok for bulk mailing if you are not using safe mode and the messages are small. Otherwise you may run into inconviniences.

    If you are using Linux/Unix it is more recommended a a solution that uses sendmail or equivalent directly because you have more control over details that may make significant different in terms of mailing queueing performance.

    I use this MIME message composing and sending class.

    It was specifically optimized for bulk mailing. It supports several delivery methods (mail, sendmail, qmail, SMTP, Windows pickup, etc..) You just need to call a function named SetBulkMail to hint the class to optimize its behavior for sending messages to many recipients, regardless of the delivery method. It makes a big difference, especially when you are using sendmail or Exim as MTA.

    Other than that, if you are not personalizing message bodies, the class has a variable to tell it to cache the message bodies between deliveries. This saves a lot of time by only building the message body once. You can still personalize message headers for each recipient.

    I use this class for sending over 4 million newsletter messages a month. The performance optimization options that I mentioned made a big difference. Queueing between 30 and 40 messages per second are typical figures.
    Manuel Lemos

    Metastorage - Data object relational mapping layer generator
    PHP Classes - Free ready to use OOP components in PHP

  4. #4
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    16,426
    Mentioned
    160 Post(s)
    Tagged
    1 Thread(s)

    mail

    Quote Originally Posted by mlemos
    and the messages are small.
    My nessages consist of a few lines of plain text only.
    Quote Originally Posted by mlemos
    between 30 and 40 messages per second
    I dont know what the "per second" rate of my script would be, I put a delay between the sends to avoid any potential queing problems. After reading mlemos' post, my script, although adequate for my needs at present, does seem in need of replacement. (at least if my newsletter subscriptions ever get bigger)

  5. #5
    SitePoint Addict
    Join Date
    Apr 2002
    Posts
    330
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Mittineague
    I dont know what the "per second" rate of my script would be, I put a delay between the sends to avoid any potential queing problems.
    Yes, a delay is wise if you are short of disk space, your script takes too much CPU or you are consuming too much instant bandwidth. I have another class that checks disk space and CPU usage but it only works on Linux.


    After reading mlemos' post, my script, although adequate for my needs at present, does seem in need of replacement. (at least if my newsletter subscriptions ever get bigger)
    Maybe. Usually you hit some hosting environment limit or you are warned by your hosting people that you are taking too much resources when your newsletter subscriber count grows. So, you need to upgrade hosting package or make the deliveries more efficient.

    Other than that, it is also important to compose messages properly according to MIME standards to prevent that the message arrived corrupted or be confused with SPAM. There are many details to considers about these aspects. A good ready to use MIME message composing and sendind class may solve most of the concerns.
    Manuel Lemos

    Metastorage - Data object relational mapping layer generator
    PHP Classes - Free ready to use OOP components in PHP

  6. #6
    SitePoint Member
    Join Date
    Sep 2005
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHPmailer not so bad

    In response the the PHPmailer user. I've had good luck with PHPmailer. My largest send is about 15,000 html emails. I do this at least once a week. One thing to make sure is that you are unsing the most recent version of PHPmailer. For a while an older version I used was sending duplicates. This was solved by updating to the most recent version. I also have a system by where I mark each email in my email cue table as pending when its queryed and sent when it's sent. There was a time when I was re-querying the same recipient before the server had a chance to send the intitial email. I also have good luck using the smarty template in conjunction with PHPmailer. To track bounces I use a company called bbounce.com and I use the 1 pixel image in my html emails to get a feel for who opened them. It's been quite a learning curve for me and it's still continueing. Good luck ...

  7. #7
    SitePoint Zealot
    Join Date
    May 2001
    Posts
    193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks, I'd been using phpmailer(the latest) and just find it too unreliable. Weird errors would crop up like "can't load language blah, blah" only on occasion or just crap out all together. I dealt with it for about a year, but can't go on.

  8. #8
    SitePoint Enthusiast
    Join Date
    Jan 2006
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    XPertMailer is a PHP class that you can use to send encoded MIME type e-mail messages (text, HTML, HTML embedded images, attachments) towards a localhost, client or relay SMTP servers with optional authorisation. Cc and Bcc functionality are included.
    The XPertMailer class functions are optimised to execute in a very small time and allso to be easy to use. This reduces the size of the code and the time required to write it.
    The names of the public functions in the XPertMailer class are eloquent so that they can be used without any confusions being made.
    The data sendig is done according to the RFC 821 and RFC 2821, and the message type is in conformity with the RFC 2045, RFC 2046, RFC 2047, RFC 2048, RFC 2049, and RFC 2822.

    A simple example how to use:

    PHP Code:
    <?php

    set_time_limit
    (0);

    // optionaly, you can disable display errors
    error_reporting(false); // from php (generally)
    define('PRINT_ERROR'false); // from XPertMailer class

    // path to XPertMailer class file
    require_once 'XPertMailer.php';

    /**
     * send to multiple e-mail addresses - text/html format
     * with two HTML embedded images and two attachment files
     * --------------------------------------
     */

    // optionaly, you can use an relay host name, if fail, send directly to the client
    $mail = new XPertMailer(SMTP_RELAY_CLIENT'relay-host-name.com');

    // set authentication username and password for relay host and auth type (here AUTH_LOGIN, by default is AUTH_DETECT)
    $mail->auth('username''password'AUTH_LOGIN);

    // optionaly, set the port number value for SMTP server socket connections, default are 25
    $mail->port(25);

    // optionaly, set time out for SMTP server socket connections (in secounds), default are 10
    $mail->timeout(30);

    // set priority high (default is normal)
    $mail->priority(P_HIGH);

    // set from mail address and optionaly from name
    $mail->from('my@account.com''My Name');

    // set each header name and value
    $header['Cc'] = 'user1@example1.com, anotheruser1@example2.com';
    $header['Bcc'] = 'user2@example3.com, anotheruser2@example4.com';
    $header['Reply-To'] = 'reply@domain.com';
    $header['X-Whatever'] = 'description';

    // set additional header informations
    $mail->headers($header);

    // set HTML embedded images name and optionaly you can rename them
    // if the file is not in this directory, write the path name (/path/name.image_extension)
    // Attention: do not include path name in the rename file like /path/rename.gif, put only rename.gif
    $imgs[] = 'image1.jpg';
    $imgs['rename.gif'] = 'image2.gif';

    // attach HTML embedded images
    $mail->attach($imgsATTACH_HTML_IMG);

    // set attachment files name and optional you can rename them
    // if the file is not in this directory, write the path name (/path/name.file_extension)
    $file['new.zip'] = 'archive1.zip';
    $file[] = 'archive2.tar.gz';

    // attach files
    $mail->attach($fileATTACH_FILE);

    // set html value
    // Attention: do not include image path name in HTML source like <img src="/path/name.jpg">, put only <img src="name.jpg">
    $html '<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">
    <html>
    <body>
    <img src="image1.jpg" border="0"><br>
    <b><u><i>next image</i></u></b> :-)<br>
    <img src="rename.gif" border="2"><br>
    <font color="red">message html red here</font>
    </body>
    </html>'
    ;

    // send to multiple e-mail addresses and optionaly you can set charset value (here UTF-8, by default is ISO-8859-1)
    // as you can see, the text/plain message is required because not all mail clients can currently support HTML messages
    $send $mail->send('touser@domain1.com, toanotheruser@domain2.com''subject here''text version'.CRLF.'new line'$html'UTF-8');

    // compare the result and print a message
    echo $send "Done." "Error.";

    // some useful for debugging
    echo "<br>Server response: ".$mail->response;

    ?>
    For more informations, visit: www.xpertmailer.com


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •