473,406 Members | 2,273 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,406 software developers and data experts.

multithread a process

Hello,

can i use php to multithread mail() or something similar? in my company
i need to send multiple copies of email to a few hundred ppl affilated
and on my list.

instead of calling mail over and over again i would like to thread this
process.

could someone point me to some documentation or perhaps an example of
where to start with this?

cheers

-jpdr
TTG

Jul 16 '05 #1
12 8592
On Mon, 18 Aug 2003 14:22:54 +0000 (UTC) in
<message-id:bh**********@hercules.btinternet.com>
haptiK <ha****@yahoo.com> wrote:
Hello,

can i use php to multithread mail() or something similar? in my
company i need to send multiple copies of email to a few hundred ppl
affilated and on my list.

instead of calling mail over and over again i would like to thread
this process.

could someone point me to some documentation or perhaps an example of
where to start with this?

cheers

-jpdr
TTG

bcc the mails?

Regards,

Ian
--
Ian.H [Design & Development]
digiServ Network - Web solutions
www.digiserv.net | irc.digiserv.net | forum.digiserv.net
Programming, Web design, development & hosting.
Jul 16 '05 #2
hello Ian :)
Thanks for your response.

I'm not completly sure what Bcc does, but i do know it is a Blind Carbon
Copy meaning everyone gets a copy of the email without anyone else
knowing who recieved it.

I would still like to discuss threading the mail process.

any other ideas?

Ian.H [dS] wrote:
On Mon, 18 Aug 2003 14:22:54 +0000 (UTC) in
<message-id:bh**********@hercules.btinternet.com>
haptiK <ha****@yahoo.com> wrote:

Hello,

can i use php to multithread mail() or something similar? in my
company i need to send multiple copies of email to a few hundred ppl
affilated and on my list.

instead of calling mail over and over again i would like to thread
this process.

could someone point me to some documentation or perhaps an example of
where to start with this?

cheers

-jpdr
TTG


bcc the mails?

Regards,

Ian


Jul 16 '05 #3
On Mon, 18 Aug 2003 14:42:38 +0000 (UTC) in
<message-id:bh**********@hercules.btinternet.com>
haptiK <ha****@yahoo.com> wrote:
hello Ian :)
Thanks for your response.

I'm not completly sure what Bcc does, but i do know it is a Blind
Carbon Copy meaning everyone gets a copy of the email without anyone
else knowing who recieved it.

Yup, pretty much you'd set the 'To' header to your own mail address,
then list the others as people to BCC.

This would then just use a single mail() call rather than a looped
version.


I would still like to discuss threading the mail process.

any other ideas?

Fair enough.. but can't offer any advice / ideas on this part.. not
actually thought it in the past tbh.. so I'm at a loss for info there
=)

Regards,

Ian

--
Ian.H [Design & Development]
digiServ Network - Web solutions
www.digiserv.net | irc.digiserv.net | forum.digiserv.net
Programming, Web design, development & hosting.
Jul 16 '05 #4
haptiK wrote:

[snip BCC]
How then would this behave if im sending thousands of emails to my users
as opposed to threading the mail process? over all performance?


Far better. It's the mail server doing the work, not the PHP script. This
also means you don't disclose everybody's email address, which isn't a very
nice thing to do to people who don't want to get spammed.
--
Jim Dabell

Jul 16 '05 #5
Hi,

haptiK wrote:
How then would this behave if im sending thousands of emails to my users
as opposed to threading the mail process? over all performance?

thanks again for your response.. im new to the theory of threaded
processes and they sound interesting but if im headed down the wrong
trail with this i appreciate your patience.


Using Bcc, with the Bcc field containing the thousands of addresses,
means the the PHP process only sends one email to your mail server very
quickly. It is then up to the mail server to copy it out to everyone on
the Bcc list. This is also more efficient for the Internet, as if 200
people at example.com need a copy, your mail server will pass 1 copy to
example.com's email server with the 200 recipients listed, and
example.com's mail server will copy that message to all 200 people,
saving a lot of Internet bandwidth.

You couldn't easily use multithreading easily for what you want, as the
PHP process (and so page transfer) won't finish until all the threads
finish (you could possibly make your web server stop the request by
closing the filehandle, but its not guaranteed - your web server might
wait until it can reap the process).

You could use program execution functions (eg fork() and exec() under
Unix, or your OS moral equivilent) to send the messages from another
process and then have the main process return before the other one, but
check you don't end up with zombies.

Most Internet people would prefer you use the 1st method,

Bcc: a@example.com, b@example.net, c@example.org

Because it saves bandwidth, and if two addresses are mapped to the same
account they often won't get duplicates, but it does mean you can't
'personalise' the emails. But it also neatly puts the time-to-send
problem off PHP and on to the mail servers, optimised to do the job :-)

Regards,

Luke

Jul 16 '05 #6
Greetings Mr Ross.

Fantastic argument and I understand completly now why Bcc: is the best
option over trying to thread via php.

Thank you for your timely responses everyone.

- jpdr
TTG

Luke Ross wrote:
Hi,

haptiK wrote:
How then would this behave if im sending thousands of emails to my
users as opposed to threading the mail process? over all performance?

thanks again for your response.. im new to the theory of threaded
processes and they sound interesting but if im headed down the wrong
trail with this i appreciate your patience.

Using Bcc, with the Bcc field containing the thousands of addresses,
means the the PHP process only sends one email to your mail server very
quickly. It is then up to the mail server to copy it out to everyone on
the Bcc list. This is also more efficient for the Internet, as if 200
people at example.com need a copy, your mail server will pass 1 copy to
example.com's email server with the 200 recipients listed, and
example.com's mail server will copy that message to all 200 people,
saving a lot of Internet bandwidth.

You couldn't easily use multithreading easily for what you want, as the
PHP process (and so page transfer) won't finish until all the threads
finish (you could possibly make your web server stop the request by
closing the filehandle, but its not guaranteed - your web server might
wait until it can reap the process).

You could use program execution functions (eg fork() and exec() under
Unix, or your OS moral equivilent) to send the messages from another
process and then have the main process return before the other one, but
check you don't end up with zombies.

Most Internet people would prefer you use the 1st method,

Bcc: a@example.com, b@example.net, c@example.org

Because it saves bandwidth, and if two addresses are mapped to the same
account they often won't get duplicates, but it does mean you can't
'personalise' the emails. But it also neatly puts the time-to-send
problem off PHP and on to the mail servers, optimised to do the job :-)

Regards,

Luke


Jul 16 '05 #7
haptiK wrote:
Thanks for your response, yes actually avoiding spam is a major
intention here.. thank you for your response i will take this into
account.


Oops, sorry, I forgot the context for a second. There's no problem with
sending individual mails from an email disclosure point of view, only when
CCing (instead of BCCing). The rest applies though - you are essentially
just supplying the mail server with the email and a list of addresses,
rather than an individual email for each address.
--
Jim Dabell

Jul 16 '05 #8
On Tue, 19 Aug 2003 19:25:35 +0200 in
<message-id:bh************@news.t-online.com>
Jochen Buennagel <za**@buennagel.com> wrote:
haptiK wrote:
Fantastic argument and I understand completly now why Bcc: is the
best option over trying to thread via php.


There is a (growing) problem with this: A number of email services
(most notably hotmail) have started to classify emails as spam if the
recipient is not in the "To:" or "Cc:" fields.

ZangBunny

Sounds like another good enough reason not to use Hotmail =)

Regards,

Ian

--
Ian.H [Design & Development]
digiServ Network - Web solutions
www.digiserv.net | irc.digiserv.net | forum.digiserv.net
Programming, Web design, development & hosting.
Jul 16 '05 #9
Jochen Buennagel wrote:
haptiK wrote:
Fantastic argument and I understand completly now why Bcc: is the best
option over trying to thread via php.


There is a (growing) problem with this: A number of email services (most
notably hotmail) have started to classify emails as spam if the
recipient is not in the "To:" or "Cc:" fields.


Really? That practice would give an amazing amount of false positives.
Basically any legitimate bulk mail. I've just tested it with Hotmail, and,
with the default settings, BCCed email gets through just fine. It may be
that at higher spam filtering settings, it does not get through, but
Hotmail explicitly tells you that you could miss legitimate email with
these settings, so I'd regard that as acceptable loss. After all, if
that's all it takes to get classed as spam, then they must be missing more
than just a few emails from you.
--
Jim Dabell

Jul 16 '05 #10
I know your goal isnt to confuse me on purpose but does bcc pose these
problems or not? should i still be investigating multithreaded email?

:)

- jpdr
TTG

Jim Dabell wrote:
Jochen Buennagel wrote:

haptiK wrote:
Fantastic argument and I understand completly now why Bcc: is the best
option over trying to thread via php.


There is a (growing) problem with this: A number of email services (most
notably hotmail) have started to classify emails as spam if the
recipient is not in the "To:" or "Cc:" fields.

Really? That practice would give an amazing amount of false positives.
Basically any legitimate bulk mail. I've just tested it with Hotmail, and,
with the default settings, BCCed email gets through just fine. It may be
that at higher spam filtering settings, it does not get through, but
Hotmail explicitly tells you that you could miss legitimate email with
these settings, so I'd regard that as acceptable loss. After all, if
that's all it takes to get classed as spam, then they must be missing more
than just a few emails from you.


Jul 16 '05 #11
well this actually brings up something in the requirements list that i
failed to realize yesterday. The subjects of the email are meant to
distinctly identify each email recipient on a personal level. this is of
course to maintain a professionalism when speaking to our customers etc..

i think because of this BCc: is out of the question.

damn. i was really excited about the use of BCc, but i guess its back to
square one and discussing multithreading or spawning new procs with php.

can someone discuss this with me? is it sensible to use system()
passthru() or exec() to pass the job of mailing over to a shell
script... i just dont know where to go with this now...


Luke Ross wrote:
Hi,

haptiK wrote:
I know your goal isnt to confuse me on purpose but does bcc pose these
problems or not? should i still be investigating multithreaded email?

The general consensus is no. My Yahoo webmail is perfectly capable of
receiving them, and other people says hotmail is fine. Some really
really braindead spamfilters might reject them, but then braindead spam
filters can reject anything for any reason so it's not really worth
worrying about it. With any sort of list the odd email will come back as
people change their email address, mess up their filtering, go over
quota, etc.

In the Bcc vs multiple send argument, I'd be guided about whether you
need to send different email content to different people. If you want
the same content to go to lots of people, you probably want to use Bcc.
If you want different email content to go to different people, then your
only choice is multiple send, probably by starting another process.

Hope that clarifies things!

Regards,

Luke


Jul 16 '05 #12
Hi,

haptiK wrote:
well this actually brings up something in the requirements list that i
failed to realize yesterday. The subjects of the email are meant to
distinctly identify each email recipient on a personal level. this is of
course to maintain a professionalism when speaking to our customers etc..
It always amuses me that customers feel more important if the email
starts "Dear [name here]". But it does seem to make a difference to
people, granted.
i think because of this BCc: is out of the question.
Yes.
damn. i was really excited about the use of BCc, but i guess its back to
square one and discussing multithreading or spawning new procs with php.

can someone discuss this with me? is it sensible to use system()
passthru() or exec() to pass the job of mailing over to a shell
script... i just dont know where to go with this now...


As mentioned before, I think you'll find multithreading a) difficult and
b) not very effective. It does depend a little on the OS you're using
though.

I would personally write a script in Perl or something like that to
email everyone, and just have PHP invoke it with something like
system("/bin/bash myscript.pl &"); to background it (assuming you're
using a unix). If you need a PHP solution you could fire off a PHP CGI
executable to do something similar for you. It's a little crude, but by
far the quickest and easiest way to do this I'd have thought.

Luke

Jul 16 '05 #13

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

Similar topics

4
by: dbmethods | last post by:
Could someone give a hint on how to do multithread programming with PHP scripting here? Thanks
4
by: Michael Shestero | last post by:
Hello. I have some function f(stream* out) that makes text-output into stream (*out) i.e. (*out)<<"Hello"<<endl;. The (*out) can be cout, ofstream, a strstream, etc. This function working in the...
0
by: r_obert | last post by:
Hello, I'm trying to create a worker thread for my VC++ program, and was wondering whether I should be linking with the Multithread /MT or Multithread DLL /MD option? I'm not quite sure, in...
4
by: zbcong | last post by:
Hello: I write a multithread c# socket server,it is a winform application,there is a richtextbox control and button,when the button is click,the server begin to listen the socket port,waiting for a...
2
by: zhebincong | last post by:
Hello: I write a multithread c# socket server,it is a winform application,there is a richtextbox control and button,when the button is click,the server begin to listen the socket port,waiting...
5
by: Ekempd | last post by:
Hi I need some advice about this situation an how I'm current handling it I hava a ASP.NET solution that in some point start multiples lenghty verification agains diferent databases, my big...
6
by: jmartin | last post by:
Hi, I have made a multithread version of a program (load a file into database), and with two processors I get the double of time in the multithread than in the process (unithread) version. I...
0
by: Gordon Cone | last post by:
I am currently debugging a deadlock in a multithread C# application. It makes lots of calls to legacy unmanaged code. The application runs on windows sever 2003 and uses the sever version of the...
0
by: Gordon Cone | last post by:
I am currently debugging a deadlock in a multithread C# application. It makes lots of calls to legacy unmanaged code. The application runs on windows sever 2003 and uses the sever version of the...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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,...
0
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...
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
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.