Old 3rd September 2007, 03:39
toffie toffie is offline
Junior Member
Join Date: Sep 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default HowTo: Sending Email From PHP

to begin with, great article!

second, it says in the end of the article that the mail() function is
not good to send several mails after each other as the function opens up
and closes the smtp connection for every mail sent..

how to fix this then?

can you get around it just by using CC or BCC?
or are there any other solutions?

I'm not after spamming I'm after a good solution to be able to send
newsletters from my own site..
Reply With Quote
Sponsored Links
Old 4th September 2007, 15:00
sjau sjau is offline
Local Meanie
Join Date: Apr 2006
Location: Switzerland
Posts: 1,158
Thanks: 4
Thanked 58 Times in 54 Posts

you can easily set multiple recipients:

$to = 'john@doe.com , jane@doe.net';
Reply With Quote
Old 6th September 2007, 09:01
toffie toffie is offline
Junior Member
Join Date: Sep 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts

but thats not what I asked for.. I know you can have several To, CC and BCC..

but will that affect the smtp server in that way it can block the email sender?
Reply With Quote
Old 7th September 2007, 16:05
falko falko is offline
Super Moderator
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,752 Times in 2,582 Posts

You can send mails directly via SMTP. You can find some PHP classes that do that here: http://www.phpclasses.org/browse/class/2.html
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
Old 7th September 2007, 16:43
chuckl chuckl is offline
Senior Member
Join Date: May 2007
Location: Uxbridge, Middlesex, UK
Posts: 166
Thanks: 1
Thanked 20 Times in 20 Posts

I think the caution is really about the fact that mail() is a very rudimentary implementation. Any error message is along the lines of 'Something went wrong somewhere, mail send failed', which is a nightmare if it happens in the middle of sending 200 emails.

For that purpose you need something a bit more 'industrial', I'd recommend you look at Swiftmailer, written as a successor to phpMailer, it's extremely powerful and has every bell and whistle you could wish for - batch sends etc, it's actively developed and supported, and very easy to implement.


Disclaimer - I have absolutely no ties or association with the product, other than that I looked at many different solutions to replacing phpMailer, and this was the best I found, and I am using it for that purpose.
Reply With Quote


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Freebsd 6.1 support misterm Installation/Configuration 10 9th April 2009 10:29
php eating cpu shajazzi Server Operation 15 15th August 2007 02:19
Slightly Confused (DNS & Server Help) JohnnyBGoode Installation/Configuration 26 14th August 2007 10:54
Apache2 Freezes celtic Server Operation 31 28th May 2007 18:18

All times are GMT +2. The time now is 16:26.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.