473,782 Members | 2,479 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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($emai laddress, $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($emailaddr ess, $emailsubject, $msg, $headers);
}

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

$fromaddress = "";

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

Jul 5 '07 #1
1 2760
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($emai laddress, $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($emailaddr ess, $emailsubject, $msg, $headers);

}

$message = "<h2>Hello World</h2>";
$subject = "Test Email";
$to = "myem...@addres s.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
2894
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 webmail. And I know they work on *my* Outlook Express. But I have one person (I know of) who gets the emails as plain text, so she sees the HTML code for the email instead of its proper representation. She has, like myself, OE6, and other html emails...
40
11899
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 following import win32com.client
10
4987
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 working with we put these mailshots in the bcc field of the mails. This can sometimes cause a problem as we are getting alot of mails bounced back. I would like to write a script to have these emails sent out individually using the to: field of the...
2
9242
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 - I see hebrew, it is just sending by myself using *.aspx scripts). In web.config I have the following : <configuration> <system.web>
2
2283
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 emails to and from the customers to be stored into the database. Is it quite easy to set it up that if an email is received at a certain email address, this is automatically inserted into the database? I assume it is also easy to set it up...
3
3499
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 different time by a minute or so. I also tried to count the number of emails it is sending by using the intEmail = intEmail + 1, but the number is always 1.Could anyone tell me why this is happening or give me advice on how to change it. Thanks...
5
2448
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 each member to choose different category of products or all products newsletter.
1
1214
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
3438
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 to a PDA/palmtop via POP3. The PDA uses Windows Mobile software. Since using the PDA, I have had the problem of emails disappearing from the Yahoo! server. However I think I now understand how to avoid this. It seems that Windows Mobile is...
0
9641
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10313
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10146
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9944
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2875
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.