Connecting Tech Pros Worldwide Forums | Help | Site Map

I am a bit confused about mail(), phpmailer and PEAR:mail

Familiar Sight
 
Join Date: Jan 2009
Posts: 165
#1: Apr 11 '09
I am building my subscriber list which is held in the
mySQL database "client" table and I want to start sending them a newsletter.

My list will probably get up to around 20,000

I would like know if emails are getting through of if they are being rejected, so I can keep the subscriber list clean.

I would also like to send HTML email but with an alternative text email for those that don't except HTML.

Now, I was just going to use php mail() command
from within my own script which simple loops through the client
table, but I read this at php.net:

Quote:
Note: It is worth noting that the mail() function is not suitable for larger volumes of email in a loop. This function opens and closes an SMTP socket for each email, which is not very efficient.
For the sending of large amounts of email, see the » PEAR::Mail, and » PEAR::Mail_Queue packages.
It has also been suggested that I use phpMailer or SwiftMail.

Now,
I have to admit I am a bit confused though.

Having read a few tutorials about all this

There is phpMailer
and there is SwiftMail
and there is PEAR:Mail

Are these three just similar methods of doing the same thing ?
i.e. they are all OOP classes that in the end use the
php mail() command ?


Then there is Sendmail.

I think sendmail is a server program like postfix - is that right ?

And does the mail() command send the email out using the server program ( sendmail or postfix ) ?

I have downloaded phpMail and about to install it but,
to be honest I am not sure is setting up phpMailer is the way to go
, would PEAR be better ( or even Swift) ?

Can't use both I guess if they do the same thing !!

Would very much appreciate it if someone could explain the relationship of all these "bits" of the puzzle.

Thanks
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,936
#2: Apr 11 '09

re: I am a bit confused about mail(), phpmailer and PEAR:mail


The first problem you ask about (knowing whether the mail is sent successfully) is a hard one to do reliably. Because you cannot check if an email is valid by just sending an email to an address (the email client for that email address will not tell you if it's valid - that would be a spammers wet-dream), you'd have to have a link inside the email that the user should follow to confirm they are reading the news letters, and then delete the emails that don't reply. However, this isn't reliable because not all people check their emails consistently.

Sending an HTML email and a plain text email to the same address is over-kill. Have an option (stored in your database) that the user selects, to send either HTML or plain text.

I'm not a fan of PEAR packages. SwiftMailer is pretty much the de facto standard when sending emails now. I'm not sure if they use the mail() method, but I think I have read that they don't and that is why they're a good tool to use.

SwiftMailer is the best option. Reason being: it is a well structured library / class; has many different features; and generally does everything you need from a mail class. It also allows for plugins to extend it's functionality.

You could use both, but what would be the point?

Go SwiftMailer - not PHPMailer because it is no longer actively developed / the documentation is little, and, compared to SwiftMailer, it lacks a lot of functionality.

Hope this helps,

- mark.
Newbie
 
Join Date: Jul 2008
Posts: 22
#3: Apr 13 '09

re: I am a bit confused about mail(), phpmailer and PEAR:mail


if you have your server details handy with you. I think that the mail function is a best option.
Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,642
#4: Apr 13 '09

re: I am a bit confused about mail(), phpmailer and PEAR:mail


I have to disagree with this. Markus is right recommending Swiftmailer (although I'm of the opinion that writing a html/text multipart message is not an overkill)
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,936
#5: Apr 13 '09

re: I am a bit confused about mail(), phpmailer and PEAR:mail


Quote:

Originally Posted by Dormilich View Post

I have to disagree with this. Markus is right recommending Swiftmailer (although I'm of the opinion that writing a html/text multipart message is not an overkill)

I'm not against sending an hmtl/text multipart message, but against send a plain text message AND an html one, which is what I believe the OP is doing.

Quote:

Originally Posted by op

I would also like to send HTML email but with an alternative text email for those that don't except HTML.

- mark.
Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,642
#6: Apr 13 '09

re: I am a bit confused about mail(), phpmailer and PEAR:mail


ah, that makes sense.
Reply