PHP mail() function
Is this acceptable to use for sending up to 10 emails with the same data in the same script?
I know it opens/closes server mail connections each time so is not efficient for large volumes, but what's a realistic threshold for this?
Signature links on this forum are NO-follow! - This means spam is futile!

Shaggy posted this at 17:28 — 19th June 2009.
They have: 114 posts
Joined: Dec 2008
Speaking as someone who has never had to run a PHP script that sends mail on anything but the machines I admin myself - and so can only upset myself, I think ten is absolutely reasonable.
How is that for a disclaimer?!
The threshold might depend on the outgoing mail handler available locally to PHP. For instance, I typically configure to allow 25 simultaneous local SMTP 'sessions'. If you are consistently saturating the available connections - that wouldn't be a good thing.
Cheers,
Shaggy
greg posted this at 17:38 — 19th June 2009.
He has: 1,580 posts
Joined: Nov 2005
It's a public form that will email however many times the form is being used by X visitors.
Hmm, so potentially more than 10.
What's a good alternative? Only need something simple to send some basic form text/tick box results etc.
Signature links on this forum are NO-follow! - This means spam is futile!
Shaggy posted this at 19:56 — 19th June 2009.
They have: 114 posts
Joined: Dec 2008
So, filling a form results in a piece of email being produced?
If that is the case and you run into walls without getting help from your provider, it is time to find a new one. I can't think of anything much more legitimate than a form triggering the creation of an email...
(assuming of course, the form is secured enough that it doesn't become a spam gateway...)
Cheers,
Shaggy.
teammatt3 posted this at 19:14 — 19th June 2009.
He has: 2,076 posts
Joined: Sep 2003
I don't see a problem with it. If you don't want to open and close a connection every time, you can put the TO field as the email addresses separated by commas:
<?phpmail('matt@example.com, <a href="mailto:greg@example.com">greg@example.com</a>, shaggy@example.com', 'Subject', 'Body', 'FROM: web@example.com');
?>
I think that would work.
My Site | Regular Expression Tester
pr0gr4mm3r posted this at 19:26 — 20th June 2009.
He has: 1,423 posts
Joined: Sep 2006
If you have multiple address in the To field, then all those address are visible to all the recipients, wich is not a good idea.'
I don't think sending them out separately is a bad idea when only doing 10.
PHP Starter
greg posted this at 22:34 — 20th June 2009.
He has: 1,580 posts
Joined: Nov 2005
It's likely to be less than 10 emails per form submitted anyway.
But as it's public, and submitting the form initiates a potential 5-10 emails per form submitted (i.e. per user using the form), is this still ok if multiple people use it simultaneously all day.
I don't think this will be the case, and probably more realistically a few users per hour, but I'm just considering potential future eventualities.
Signature links on this forum are NO-follow! - This means spam is futile!