Some of the email not sent when specifying a many recipient.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
jlising
Forum Commoner
Posts: 33
Joined: Mon Mar 19, 2007 1:48 am
Location: Pampanga, Philippines
Contact:

Some of the email not sent when specifying a many recipient.

Post by jlising »

Hello!

I have a problem in sending email. I have a script that sends an email to multiple recipients (above 100 recipients). I'm avoiding the use of bcc: or cc: field that's why I used a loop to send email using the To: field. But some of the emails were not sent. Is there an efficient way to solve this problem?

Many Thanks!
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

Swiftmailer has some libraries to connect directly to the SMTP server to send email, which is far more efficient than mail() if your server allows for it.
User avatar
jlising
Forum Commoner
Posts: 33
Joined: Mon Mar 19, 2007 1:48 am
Location: Pampanga, Philippines
Contact:

Post by jlising »

I am using a php mailer class. I don't want to start over again to avoid reconfigurations. Please give me some hints how to solve my problem.
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

Well, if you're mailer class will connect directly to the SMTP server, give that a shot. Otherwise, you'd probably have better luck sending only a few at a time, by either setting up a cronjob or sleep()ing a few times over the course of the loop.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

PHPMailer used to just hang for me sometimes if I tried sending that many emails. Anyway, some (read, most) servers have limits on how many emails you can send in a single connection. You need to disconnect and reconnect before that limit is hit. SwiftMailer provides and anti-flood plugin for this but if you're srongly attached to PHPMailer it won't be too tricky to just track the number of emails sent in a loop. Have you checked for errors?
User avatar
jlising
Forum Commoner
Posts: 33
Joined: Mon Mar 19, 2007 1:48 am
Location: Pampanga, Philippines
Contact:

Post by jlising »

Hello d11wtq!

I'm totally revising my scripts and I will use the Swift Mailer. I found out this class has the method name batchsend(), unfortunately, I cannot use this method because each message I will send to each recipient is customized (e. g. the salutation Dear Mr. Lising). That means, I need to go on with the looping statement to send emails.

Is there an easiest or very efficient way to do the same aside from what I think?

Thanks!
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

jlising wrote:Hello d11wtq!

I'm totally revising my scripts and I will use the Swift Mailer. I found out this class has the method name batchsend(), unfortunately, I cannot use this method because each message I will send to each recipient is customized (e. g. the salutation Dear Mr. Lising). That means, I need to go on with the looping statement to send emails.

Is there an easiest or very efficient way to do the same aside from what I think?

Thanks!
How to customize messages for each recipient in a batch

;)
Post Reply