Jump to content

mail function content issue


denoteone

Recommended Posts

I need to add a whole bunch of variables to one variable and then send that variable in a email. But my page keeps breaking. I have an array  for the titles of the product and  an array from my my form with price values.

 

$txt = ''.$products2[0] .': '.$_POST[$products2[0]].'<br/>
'.$products2[1] .': '.$_POST[$products2[1]].'<br/>
'.$products2[2] .': '.$_POST[$products2[2]].'<br/>
'.$products2[3] .': '.$_POST[$products2[3]].'<br/>
'.$products2[4] .': '.$_POST[$products2[4]].'<br/>
'.$products2[5] .': '.$_POST[$products2[5]].'<br/>
'.$products2[6] .': '.$_POST[$products2[6]].'<br/>
'.$products2[7] .': '.$_POST[$products2[7]].'<br/>
'.$products2[8] .': '.$_POST[$products2[8]].'<br/>
'.$products2[9] .': '.$_POST[$products2[9]].'<br/>
'.$products2[10] .': '.$_POST[$products2[10]].'<br/>
'.$products2[11] .': '.$_POST[$products2[11]].'<br/>
'.$products2[12] .': '.$_POST[$products2[12]].'<br/>
'.$products2[13] .': '.$_POST[$products2[13]].'<br/>
'.$products2[14] .': '.$_POST[$products2[14]].'<br/>
'.$products2[15] .': '.$_POST[$products2[15]].'<br/>
'.$products2[16] .': '.$_POST[$products2[16]].'<br/>
'.$products2[17] .': '.$_POST[$products2[17]].'<br/>
'.$products2[18] .': '.$_POST[$products2[18]].'<br/>
'.$products2[19] .': '.$_POST[$products2[19]].'<br/>
'.$products2[20] .': '.$_POST[$products2[20]].'<br/>
'.$products2[21] .': '.$_POST[$products2[21]].'<br/>
'.$products2[22] .': '.$_POST[$products2[22]].'<br/>
'.$products2[23] .': '.$_POST[$products2[23]].'<br/>
'.$products2[24] .': '.$_POST[$products2[24]].'<br/>
'.$products2[25] .': '.$_POST[$products2[25]].'<br/>
'.$products2[26] .': '.$_POST[$products2[26]].'<br/>
'.$products2[27] .': '.$_POST[$products2[27]].'<br/>
'.$products2[28] .': '.$_POST[$products2[28]].'<br/>
'.$products2[29] .': '.$_POST[$products2[29]].'<br/>'';

$headers = "From:Product Prices" . "\r\n" .
"CC: [email protected]";

mail($to,$subject,$txt,$headers);

Link to comment
https://forums.phpfreaks.com/topic/196942-mail-function-content-issue/
Share on other sites

This is how I would do it.

 

You would want to make each of the '.$products2[0] .': '.$_POST[$products2[0]].' into separate variables.

 

$product_0 = '.$products2[0] .': '.$_POST[$products2[0]].';

etc.

 

Then change $txt to $message.

When you build the $message variables you want it in this format:

 

$message = $product_0n\$product_1n\etc.

 

From what I understand the mail() function can only accept certain variables and you cannot use <br/> you have to use n\.

 

There may be a better way of doing it but that's the way I know how.

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.