Jump to content

[SOLVED] mailing multiple items


timmah1

Recommended Posts

I have variables I need to email.

When I echo them out, it displays all of them (6)

echo $name."-".$val."<br>";

But, when I try to email them, I only get one

I have this for the message

$message = "<html><body><strong>Sport:</strong> {$sport}<br><strong>Activation Date:</strong> {$active}<br />";
$message .= "<strong>{$name} - {$val}</strong><br />";
$message .= "</body></html>";

 

Why do I only get one emailed, but all 6 display on the screen?

Both of them are inside the loop

 

If you need more of the code, please let me know, as I have to try and get this fixed quick.

 

Thank you in advance

Link to comment
https://forums.phpfreaks.com/topic/138237-solved-mailing-multiple-items/
Share on other sites

i am not sure, But i guess you need every loop to have there own separated variable,

Dont hold me to that i am sure your no soon.

 

Yes thinking about it, 1 variable can only show 1 thing inside it.

 

Your loop it self is not going no where, example the server for mail is not executing the php on the mail server and never will. (unless you own the mail server )

 

Your best option is to create the six variables from the array, and place them where you want

them in the mailing code .

 

 

 

I have this first

require("config.php");	
if($_POST['sport'] == "") {
	header("Location: " . $config_basedir . "setPicks.php?error=3");
}
while (list ($name,$val) = @each ($_POST['pick_'])) { 

if($val == "") {

}
else {	

$sport = $_POST['sport'];
$active = $_POST['yr']."-".$_POST['month']."-".$_POST['day'];
$spl_date = $_POST['yr_spl']."-".$_POST['month_spl']."-".$_POST['day_spl'];
$spl_time = $_POST['end'];
if($_POST['endR'] == "a"){
	$endtime = $spl_time.":00:00";
}
if($_POST['endR'] == "p"){
	$pm = $spl_time+"12:00:00";
	$endtime = $pm.":00:00";
}

$val = stripslashes($val);
$val = mysql_real_escape_string($val);

 

Then the mail

$to = "Tim <[email protected]>";
$subject = "Picks Updates";
$today = date("F j, Y h:i a");
$user = $_SESSION['SESS_EMAIL'];
}
$extra = explode(",", $val);
//$extra = explode(
$message = "<html><body><strong>Sport:</strong> {$sport}<br><strong>Activation Date:</strong> {$active}<br />";
$message .= "{$name} - {$val}";
$message .= "</body></html>";

echo $name."-".$val."<br>";



$name = "xxx";
$from = "website@xxxx";
$headers = "From: ". $name . " <" . $from . ">\r\n";
$headers .= "Content-Type: text/html; charset=\"iso-8859-1\"";
$headers .= "Content-Transfer-Encoding: 7bit";
//$headers .= 'Cc: xx@xx' . "\r\n";
$headers .= 'Bcc: xx@xx' . "\r\n";
// now lets send the email.
}
mail($to, $subject, $message, $headers);     
echo "<div align='center'>Picks have been entered<br></div>";
echo "<div align='center'><a href='setPicks.php'>Go Back</a></div><br><br>";

}

 

Easy example just set the email address your see what i mean.

 

wont work

<?php


$n=array("redarrow","luke","petter");

foreach($n as $names){

$mess=' my name is '.$names.'}';

}

$to='you@what_ever.com';


$message = $mes; 



$headers = 
        'X-Mailer: PHP/' . phpversion() . "\r\n" .
        "MIME-Version: 1.0\r\n" .
        "Content-Type: text/html; charset=utf-8\r\n" .
        "Content-Transfer-Encoding: 8bit\r\n\r\n";



if(mail($to, $subject, $message, $headers)){



echo " MAIL WAS SENT TO $to!"; 

}else{



echo " SORRY NO MESSAGE SENT TO $to";
}

?>

 

 

will work.

<?php


$n=array("redarrow","luke","petter");



$mess=' my name is '.$n[0].' <br>
        my name is '.$n[1].' <br>
        my name is '.$n[2].'';


$to='you@what_ever.com';


$message = $mes; 



$headers = 
        'X-Mailer: PHP/' . phpversion() . "\r\n" .
        "MIME-Version: 1.0\r\n" .
        "Content-Type: text/html; charset=utf-8\r\n" .
        "Content-Transfer-Encoding: 8bit\r\n\r\n";



if(mail($to, $subject, $message, $headers)){



echo " MAIL WAS SENT TO $to!"; 

}else{



echo " SORRY NO MESSAGE SENT TO $to";
}

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.