![]() |
My first Tutorial (PHP Mail())
Well first of all I would like to say thanks for viewing my first tutorial on your board. This tutorial was requested by " Danny Needs Help".
Quote:
First of all I think for such a easy script I will display a small sample code of the function in use and tell you how it works. PHP Code:
PHP Code:
|
Great tutorial and thanks for detailed content.
|
$subject = "My new mail() code!';
You used quotations, then an apostraphe :). Excellent tutorial though. |
Thanks and the subject thing was fixed.
|
Woahh! Great tutorial, Im getting ideas now, Im going to make a mailng system, were it gets the emails out of the database, and sends to everyone. Cheers for the tutorial is going to help me out alot.
|
Nice tutorial and very detailed, Thanks
|
that's really good for your first tutorial! :)
Keep up the good work :) |
maybe ive missed something but i belive that
$to = 'blah@blah.ext' . ', '; $to = 'blah@blah.ext' . ', '; $to = 'blah@blah.ext' . ', '; $to .= 'blah@blah.ext'; these variables are wrong your only continuing the last 2 (since the 3rd one will overwrite the previous two) i think it should be $to = 'blah@blah.ext' . ', '; $to .= 'blah@blah.ext' . ', '; $to .= 'blah@blah.ext' . ', '; $to .= 'blah@blah.ext'; then it will foward onto all 4 |
This is a very nice detailed tutorial, thanks for sharing with us William.
|
Great Tutorial. Good job William!
|
Pretty nice. With a few additions and some post comments from another page, you can make a Mass E-mailer :)
|
Three things.
1. As adam said : $to = 'blah@blah.ext' . ', '; $to = 'blah@blah.ext' . ', '; $to = 'blah@blah.ext' . ', '; $to .= 'blah@blah.ext'; should be $to = 'blah@blah.ext' . ', '; $to .= 'blah@blah.ext' . ', '; $to .= 'blah@blah.ext' . ', '; $to .= 'blah@blah.ext'; 2. From variable breakup Instead of using $headers = "From: Bill@Microsoft.com"; with mail($to, $subject, $body, $headers); you should use (for more flexibility) $from = "Bill.Gates@M$hit.com"; mail($to, $subject, $body, From: $headers); The variable name 'headers' is mis-leading as a header can contain any amount of information from a vast range of categories ;). 3. Pretty nice. With a few additions and some post comments from another page, you can make a Mass E-mailer - I decided to write a E-Mail Script. If you use it then please give credit to Omar Al-Kurd (me). - The script i wrote is 1 page, name can be anything and it is self-sufficient/maintaing. - If people like it alot, i may evolve it into a mailing list type thing ;). email.php PHP Code:
|
Dear All,
Thank you for all the comments. I have fixed the . part I am very sorry for not seeing that. Also about the headers thing. Your right there are tons of headers so if there is a varible called headers. Why would you wanna put: From: $headers then all the headers are going to be from. That is why I put $headers and added From: blah. So people could add more headers. If you have any comments let me know. -William Key |
Hmmm... I just relized that my script that i made may not be faulty at all but rather a problem with PHP 4.3.10 (look at the change log under 4.3.11) so i will open my script up again :).
|
Very good example. However, just for constructive criticism, I would do this instead:
PHP Code:
|
William,
Thanks for the great tutorial, and sharing it with us! I will try it out. Zeromancer, Thanks for pointing that out to us. Cheers, Nagaki |
For very large e-mail sendning quantitys you should use a email class like php mailer. http://phpmailer.codeworxtech.com/
Because as i understand the mail() function opens a connection and closes it on every call. That might be of server load concern later on. But i guess a few hundred emails is going the be allright but one would have to see. Optionally you could work in a cue system of some sort to keep the load down, maybe a delay between loops or something. Otherwise a email class would be good. /EyeDentify |
Quote:
|
Quote from phpmailer's website:
Quote:
|
Some people wish to implement a layout or maybe a little bit more detailed header information. Go to php.net/mail for more. ;) I like to use the user contributed content to mod my own script to my likings.
|
| All times are GMT. The time now is 09:28 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0