Current location: Hot Scripts Forums » Programming Languages » PHP » php form script to more then one email?


php form script to more then one email?

Reply
  #1 (permalink)  
Old 07-13-05, 04:23 PM
burnttoast burnttoast is offline
New Member
 
Join Date: Jul 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
php form script to more then one email?

Hey folks, 1st time poster.

I have a script ( Email sender by: Steve "Defender" Cunningham )
but I would like to send the form to more then 1 recipient, the send code it
PHP Code:

$youremail="allan@burnttoastdesign.net""allan74@shaw.ca"// This is the address that the information submitted will be sent to. 

This code above dosn't send to both emails but only to the 1st one. I have never had to send a form to more then 1 email before, how is this done?


Thanks for the time

Allan McCormick
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 07-13-05, 04:28 PM
burnttoast burnttoast is offline
New Member
 
Join Date: Jul 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
PHP Code:

$youremail="allan@burnttoastdesign.net"// This is the address that the information submitted will be sent to. 


$youremail="allan74@shaw.ca"
If I do it this way then it sends it only to the second email...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 07-13-05, 05:34 PM
FiRe FiRe is offline
Code Guru
 
Join Date: Oct 2004
Location: UK
Posts: 801
Thanks: 0
Thanked 0 Times in 0 Posts
do it like you would as a normal email:

PHP Code:

$youremail "allan@burnttoastdesign.net, allan74@shaw.ca, allan@msn.com"
__________________
Alexa Share <-- Trade virtual shares in websites with this online game.

codR.us <-- Submit and vote for your favorite code snippets with codR.us.

XEWeb.net <-- The ultimate PHP resource network.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 07-13-05, 10:48 PM
ttnkhoa2004 ttnkhoa2004 is offline
Newbie Coder
 
Join Date: Jul 2005
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
send n times email

i think email addresses should be saved to a file, and then(an email on a row), you read data in that file
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 07-14-05, 03:27 AM
burnttoast burnttoast is offline
New Member
 
Join Date: Jul 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by FiRe
do it like you would as a normal email:

PHP Code:

$youremail "allan@burnttoastdesign.net, [email]allan74@shaw.ca[/email], [email]allan@msn.com[/email]"

I didn't even try to do it this way LOL, thanks for the time
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 07-14-05, 03:57 AM
FiRe FiRe is offline
Code Guru
 
Join Date: Oct 2004
Location: UK
Posts: 801
Thanks: 0
Thanked 0 Times in 0 Posts
yeh most people use loops to send it to every person in turn but they forget that it works just like any other mail, by seperating multiple email addreses with a comma
__________________
Alexa Share <-- Trade virtual shares in websites with this online game.

codR.us <-- Submit and vote for your favorite code snippets with codR.us.

XEWeb.net <-- The ultimate PHP resource network.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 07-14-05, 10:04 AM
pamthieu pamthieu is offline
Newbie Coder
 
Join Date: Jul 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
For this specific case some like that can be used:

1) Create a function sendMail:
function sendMail($mFrom,$mTo,$mCC,$mBCC,$sujet,$body) {
$head = "From: ".$mFrom."\n";
$head .= "Reply-To: ".$mFrom."\n";
$head .= "CC: ".$mCC."\n";
$head .= "BCC: ".$mBCC."\n";
return mail($mTo,$sujet,$body,$head );
}

2) And Call the function sendMail:
for: $mTo="allan@burnttoastdesign.net"
$mCC="allan74@shaw.ca"
$mBCC="allan@msn.com"

Play with it.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #8 (permalink)  
Old 07-14-05, 10:39 AM
FiRe FiRe is offline
Code Guru
 
Join Date: Oct 2004
Location: UK
Posts: 801
Thanks: 0
Thanked 0 Times in 0 Posts
if your sending it to multiple recipients why do you cc and bcc it? ignore what pamthieu said my way works fine
__________________
Alexa Share <-- Trade virtual shares in websites with this online game.

codR.us <-- Submit and vote for your favorite code snippets with codR.us.

XEWeb.net <-- The ultimate PHP resource network.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #9 (permalink)  
Old 07-15-05, 10:53 AM
pamthieu pamthieu is offline
Newbie Coder
 
Join Date: Jul 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
As I said, it was specific solution for a specific case.
If anybody wants to know how to use mass Email in php, this is the complete solution.

Mysql Table:
create table massemail(name varchar(60),email varchar(60));

<?php
//DB Class Begins
class DB {
function DB() {
$this->host = "your_host";
$this->db = "your_db";
$this->user = "your_username";
$this->pass = "youy_password";
$this->link = mysql_connect($this->host, $this->user, $this->pass);
mysql_select_db($this->db);
register_shutdown_function($this->close);
}
function query($query) {
$result = mysql_query($query, $this->link);
return $result;
}
function close() {
mysql_close($this->link);
}
}
//Class ends

//Custom mail function
function sendMail($mFrom,$mTo,$sujet,$body) {
$head = "From: ".$mFrom."\n";
$head .= "Reply-To: ".$mFrom."\n";
return mail($mTo,$sujet,$body,$head);
}
//Begining of everything
$DB= new DB();//New DB instance (object)
$result = $DB->query('select * from massemail') or die('the Query is failed: ' . mysql_error());
//Sending Emails...
$sender='you@yourdomain.com';
$title='Watch out! We could do Stuff in php';
$message='Do not tell people to do this or that, but give them a concrete solution, a solution that works, a real example..';
while ($row = mysql_fetch_object($result)){
sendMail($sender,$reciepient,$title,$message);
}

?>

That's it!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #10 (permalink)  
Old 07-15-05, 10:57 AM
pamthieu pamthieu is offline
Newbie Coder
 
Join Date: Jul 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Please fix the While loop.

while ($row = mysql_fetch_object($result)){
$reciepient=$row->email;
sendMail($sender,$reciepient,$title,$message);
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Won't autorespond to simple php form Pixelpyro PHP 3 04-28-05 11:39 AM
HELP -- Perl email form !! nasos Perl 1 04-08-04 02:21 PM
100 Web Templates & 10 PHP Scripts for sale! HostersUK.co.uk General Advertisements 0 01-10-04 01:31 AM
Form to email script with unique ID # webworx Script Requests 0 07-24-03 03:55 AM


All times are GMT -5. The time now is 08:58 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.