You are viewing this site as a guest. Join our community to get your questions answered and share knowledge. Active members may advertise and ask for a website critique.

PHP mail()

He has: 1,580 posts

Joined: Nov 2005

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!

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

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!

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's picture

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:

<?php
mail
('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.

pr0gr4mm3r's picture

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.

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!