473,395 Members | 1,530 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Occasionally Get Duplicate Emails from mail()

I'm trying to spam myself :-\ with 2,000 emails, shooting for 15,000,
and I will occasionally get two identical emails. I'm putting a
$counter++ as the from and part of the subject line so I can see
what's going on. Any reason why this might happen? here's my code just
in case.

$counter=1;

function send_mail($emailaddress, $fromaddress, $emailsubject, $body,
$method) {
global $counter;

# Common Headers
if ($method == "text") {
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\n";
$headers .= "X-Priority: 3\n";
$headers .= "X-MSMail-Priority: Normal\n";
$headers .= "X-Mailer: php\n";
} elseif ($method == "html") {
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\n";
$headers .= "X-Priority: 3\n";
$headers .= "X-MSMail-Priority: Normal\n";
$headers .= "X-Mailer: php\n";
}

$from = $counter++;

$headers .= 'From: Me <'. $from . '@gmail.com>';
$msg = $body;
$msg = wordwrap($msg, 70);

$emailsubject .= " :: " . $from;

# SEND THE EMAIL
mail($emailaddress, $emailsubject, $msg, $headers);
}

$message = "<h2>Hello World</h2>";
$subject = "Test Email";
$to = "my*****@address.com";

$fromaddress = "";

for ($x=0; $x<2000; $x++) {
send_mail($to, $fromaddress, $subject, $message, "html");
}

Jul 5 '07 #1
1 2745
Ok. aside from the wierdness that outlook received the same email
twice (got 4,000 in my inbox) my gmail account gladly swollowed the
2,000 correctly. But after further thought on my problem, I'm going to
say that PHP buffered all the requests to mail, and the counter
function wasn't keeping up with my global counter so it looked like I
was getting duplicate emails. When PHP got around to processing the
actual mail, the counter had already up'ed itself and simply said
"ok".

Flaky.

On Jul 5, 10:46 am, robbiesmith79 <robbiesmit...@gmail.comwrote:
I'm trying to spam myself :-\ with 2,000 emails, shooting for 15,000,
and I will occasionally get two identical emails. I'm putting a
$counter++ as the from and part of the subject line so I can see
what's going on. Any reason why this might happen? here's my code just
in case.

$counter=1;

function send_mail($emailaddress, $fromaddress, $emailsubject, $body,
$method) {
global $counter;

# Common Headers
if ($method == "text") {
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\n";
$headers .= "X-Priority: 3\n";
$headers .= "X-MSMail-Priority: Normal\n";
$headers .= "X-Mailer: php\n";
} elseif ($method == "html") {
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\n";
$headers .= "X-Priority: 3\n";
$headers .= "X-MSMail-Priority: Normal\n";
$headers .= "X-Mailer: php\n";
}

$from = $counter++;

$headers .= 'From: Me <'. $from . '...@gmail.com>';
$msg = $body;
$msg = wordwrap($msg, 70);

$emailsubject .= " :: " . $from;

# SEND THE EMAIL
mail($emailaddress, $emailsubject, $msg, $headers);

}

$message = "<h2>Hello World</h2>";
$subject = "Test Email";
$to = "myem...@address.com";

$fromaddress = "";

for ($x=0; $x<2000; $x++) {
send_mail($to, $fromaddress, $subject, $message, "html");

}- Hide quoted text -

- Show quoted text -

Jul 5 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: dan glenn | last post by:
I'm creating HTML emails from a PHP site and sending them out to an email list (just about 40 people so far are on this list). I've tested and confirmed that these emails work in yahoo.com's...
40
by: ian | last post by:
Hi, I'm a newbie (oh no I can here you say.... another one...) How can I get Python to send emails using the default windows email client (eg outlook express)? I thought I could just do the...
10
by: Stuart Mueller | last post by:
I have an exchange server, that I sometimes use to perform mail shots to clients on our database, these can be upwards of 1000 at a time. As we don't want different clients to see who we are...
2
by: Mr. x | last post by:
Hello, I am sending emails with Hebrew contents. When receiving emails - I cannot see the Hebrew characters (it is not outlook express configuration, because when receiving emails from friends -...
2
by: Dave Smithz | last post by:
Hi there, I need to build a database that also handles emails. That is, the database is a customer list database and there is quite a lot of contact with the customers through email. We want all...
3
by: chuckdfoster | last post by:
When using this bit of code, it sends two emails most of the time. Sometimes it doesn't send two, but most of the time it does. I put the system time (Now) in the Subject and each email has a...
5
by: Jai | last post by:
Hi, I am in a problem of sending mass emails(newsletter) to my website members. Actually my problem is this: I want to send newsletter to my website members. But I had given a facility for...
1
by: =?Utf-8?B?RHJEYXZl?= | last post by:
Windows Mail (Vista) sends duplicate emails every time. I can't seem to find where to correct this problem -- Dr Dave Vista Newby
0
by: =?Utf-8?B?Q2hhcmxlcw==?= | last post by:
Like many people, I normally use Yahoo! Mail via the web and like to keep all my emails stored on the Yahoo! server. However sometimes I can’t get access to a PC/the web and I download my emails...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.