I have a working mailer script which has already started sending out mails. We need to send an email message to approximately 5,000 email addresses. I have a few problems though.

1.) It's sending out really slow. I'm guessing it's the embedding? The image is 300+kb big, is it supposed to slow the sending down like that? The mail is sending like 3 emails per minute. And it's going to take a lot of time if we want to send the email to 5000 recipients. The code is something like this:

$mail->AddEmbeddedImage("rocks.png", "my-attach", "rocks.png");
$mail->Body = 'Embedded Image: <img src="cid:my-attach"> 

2.) We have registered for an smtp which will not limit us to 100 emails per day. It's something like pay as you go and it keeps track of the messages sent. When I checked the log, there were duplicated messages. There were some recipients which were sent twice, the weird thing is it just tries to send the message twice and then moves to the next email addresses. The problem about that is that it consumes our limit from the smtp service and also adds too many queues in the mail which makes the sending even longer. My send code is something like:

if(isset($fromaddress)){
do{
$mail->AddAddress($row['email']);
$mail->Send();
$mail->ClearAddresses();
}
while ($row = mysql_fetch_array ($result));
}

And my query is something like :

SELECT * from email where id > 200

You may be wondering about my query. I was in need of having to send the mails from where it left off from timing out due to connection problems so I made a id column and I assign the number as the id of the last email address the mail was sent to. I don't know if that was wise but that was what I had at the moment. Any suggestions?

Is the email body personalized, or can you just send one email and BCC everybody?

I can send one mail and BCC everybody but wouldn't that be marked as spam?

Maybe, but you can always BCC 10 people, if that isn't marked.

A second option would be to create a cron job that sends just one email every minute. Try to reduce your image size, or switch to HTML email where you can insert an image tag, so you don't have to attach it.

commented: Definitely use an HTML email, that way you're not uploading the same image 5000 times, but once. If you need to know how to do this, I have a great tutorial from when I first had to do it. +0

I did suggest that but they insisted on this. I guess I'll have to try convincing them since the mailing is taking so much time. Any ideas on the mails which are duplicating? I haven't had any input on that :/

Probably some code issue.

I don't really see anything wrong with my code. Can you suggest any means of me testing it?

It can be a number of things. hard to say. My guess is the code times out before the update query is executed. Add logging and find out.

I'll just try to find a way somehow. Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.