PHP Classes

Newsletter

Recommend this page to a friend!

      MIME E-mail message sending  >  MIME E-mail message sending package blog  >  How Can PHP Send Emai...  >  All threads  >  Newsletter  >  (Un) Subscribe thread alerts  
Subject:Newsletter
Summary:Developing a newsletter system
Messages:14
Author:Hugo Rodrigues
Date:2007-05-09 15:59:26
Update:2008-01-08 07:45:31
 
  1 - 10   11 - 14  

  1. Newsletter   Reply   Report abuse  
Picture of Hugo Rodrigues Hugo Rodrigues - 2007-05-09 15:59:26
Hello,
I'm starting developing a newsletter system and i planning use this class to handle the mail system.

I'm not very experienced with mail systems in general. I'm studying it! So, i'd like to share my problems and experience before starting coding hard.

Actualy i'm sending the mails with the STMP server and everything works fine, but i'm dependent from the speed of the STMP server.
Sometimes a mail for 1400 users take about 12 hours to be delivered, but sometimes take about 1 week.

So i'm thinking to use some diferent methods to do that.
The options i have found in your class are: (please correct me if I'm wrong)

-SMTP - It's nice because the mails go to smpt server and it handle the messages and try again later id they failed. (A tip: i had problems of messagens get recognized by gmail/hotmail as SPAM. The problem was that i was using something like "mail.myserver.com" in the server host. i change to "localhost" and the messages now are NOT recognized as Spam.)

- php mail() - I think the message is delivered. but i cant control if the message was successfully delivered (sometimes it work, sometimes not).

- smtp_direct_delivery - I haven't use it, but i've read and i thing that php will connect direct to the smtp server of the final user e-mail, and try to delivery the e-mail message, and then i can make a report of the status of mail that have been sucessefull delivered (or not). (i think this may be the best option)

Are my notions correct?
What should be the best option?

thks!
Hugo


  2. Re: Newsletter   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2007-05-09 19:51:31 - In reply to message 1 from Hugo Rodrigues
12 hours or more to deliver a newsletter to 1400 recipients is a lot of time. Something you are doing is not very efficient.

As for the SMTP versus mail() delivery, there seems to be a misconception. When you send to SMTP server, there is never the guarantee that the message is delivered. You are just handing over the message that will probably reach the recipient later.

On the other hand, depending on which mail platform you are using (Windows, Linux/Unix) it may make a lot of different using the mail function or using an SMTP server to relay the messages.

On Linux/Unix usually the mail() function uses the sendmail program or equivalent just inject the message in a local queue. When you use SMTP, you need to establish a TCP connection to the server and when the messages is passed to the SMTP server, it just queues the message in the local queue as well.

So as you may see, using an SMTP server to relay messages to a local mailer is less efficient because it adds an extra step of using a TCP connection to send the message to the same queue.

If you are using Windows, there is a much more efficient solution that you can use to inject messages in the Microsoft Exchange pickup folder directly. That is used by the pickup delivery subclass of this package.

Other than that, if your newsletter is not personalized, the MIME message class has an option to cache message bodies so you can avoid the overhead of recreating the message when delivering it to different recipients.

If your message is personalized, but it makes little difference for each user, like using the header like "Dear $user", I suggest that you ditch that kind of personalization as you will benefit of greater queuing efficiency.

  3. Re: Newsletter   Reply   Report abuse  
Picture of Hugo Rodrigues Hugo Rodrigues - 2007-05-10 00:33:28 - In reply to message 2 from Manuel Lemos
Wow!
Thank Manuel for your fast reply!!

In first thks for the explanation.

The time i have affirmed (12h) its NOT the execution time of the php script to send the newsletter. The script run in about 2 minutes. I say 12h because the last mail that the system send is to me, and i generally get it about 12h after the php script ends.

(I don't know if this is a reliable method to check how many time was necessary to SMTP delivery 1400 mails...)

So the problem is that in my last test, it takes about 2 weeks the get my final mail. I really think this is a problem in my hosting SMTP server.

So, to avoid being Dependant on stmp server performance, i'm thinking on send the mail directly to the final recipient (smtp_direct_delivery?). I guess that in this way i could check if the mail was successfully delivered or not, and i could try again later for those who failed.

Do you think is is reliable ?

  4. Re: Newsletter   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2007-05-10 01:46:15 - In reply to message 3 from Hugo Rodrigues
The time that the messages take to leave the queue is normal. What happens is that some servers do not accept the messages immediately and your server keeps retrying forever until a timeout of several days is reached. Then your mail server simply bounces back the message to your sender. There is nothing to do about that.

What I think you should have is a bounce handler script that determines which address is bouncing and suspends the delivery of future newsletters, so your newsletter system does not bother sending anymore messages to bouncing addresses . I usually make the messages bounce to a given POP3 mailbox and then regularly process the bounced messages. I use this POP3 class:

phpclasses.org/pop3class

The direct delivery mode is not helpful in that case. You can use it, but if the first delivery attempt fails with a temporary error status, you need to resend the message later. A temporary error may be grey listing or something else.

You can still use the direct delivery mode, to run the first delivery attempt, and then you can inject the messages in the local mailer queue for the deliveries that failed, so it keeps retrying for a few days.

  5. Re: Newsletter   Reply   Report abuse  
Picture of Hugo Rodrigues Hugo Rodrigues - 2007-05-10 03:22:24 - In reply to message 4 from Manuel Lemos
Again, thks for you super fast reply! :)

Your advices help me getting more clarified about mail systems.

i have tested you pop3class and it work just fine. its a nice way to get the failure messages and then if needed disable the recipients that always get errors.

I'm doing several tests using the smtp_direct_delivery. When i send a mail to my isp account the message is successfully delivered, but i can't send mails to gmail.com (error: "Our system has detected an unusual amount of unsolicited"), and for sapo.pt (it stops responding).

I guess it is something like spamfilters(?)
there is any solution to this problem?

thks,
Hugo

  6. Re: Newsletter   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2007-05-10 05:26:49 - In reply to message 5 from Hugo Rodrigues
That may happen if you are sending your messages directly from a machine with a IP listed in a dial-up blacklist.

Many ISP add the IP ranges of their dial-up, ADSL and cable users to those blacklist on purpose, to prevent that their clients use their machines to send spam.

You may want to check your IP in the DNS Stuff site: http://www.dnsstuff.com/

  7. Re: Newsletter   Reply   Report abuse  
Picture of Hugo Rodrigues Hugo Rodrigues - 2007-05-10 22:02:28 - In reply to message 6 from Manuel Lemos
yes, it's true!
I've checked the site you have mentioned and it seems that my ip is blocked, so i have try in my hosting account and everything is working!

The porpuse of this newsletter system is not mass mail delivery, it's targeted mail, so its very important that i have a instantly message delivery status (without depending on smtp server).

I will continue making some tests using the smtp_direct_delivery and then i will post the results.

Thanks for your help!

Hugo

  8. Re: Newsletter   Reply   Report abuse  
Picture of Fede Fede - 2007-07-29 19:17:33 - In reply to message 4 from Manuel Lemos
I was going to use your pop3 class to parse the messages in an e-mail account to find out which are bounce reports.

Do you know of any class that would help me with this? Or a link to a guide on how to acomplish this task? I'm a little lost on what should I check in each e-mail.

Thanks a lot!!

  9. Re: Newsletter   Reply   Report abuse  
Picture of Fede Fede - 2007-07-29 19:35:02 - In reply to message 8 from Fede
I'm sorry, I didn't mean to post in this particular thread.

Anyway, I found a class called Bounce Handler, but I need EML messages to use it. How can I generate them from the original e-mails I download using youf POP3 class?

  10. Re: Newsletter   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2007-07-30 23:08:32 - In reply to message 9 from Fede
Use the OpenMessage function to select the message and the ReadMessage function to retrieve the message data.

 
  1 - 10   11 - 14