Jump to content

Recommended Posts

Hi,

 

Im having problems with the snippet below, the $message part.. can anyone help me with the syntax please?

 

Any help will be much appreciated..

Thanks alot

Chris

 

$message = 'Cape Town Alive - Cape Xtreme Booking Request' <br> 'Name:' . cleanPosUrl($_POST['posName']); . 'Email:' . cleanPosUrl($_POST['posEmail']); . 'Staying:' . cleanPosUrl($_POST['posStaying']); . 'Country:' . cleanPosUrl($_POST['posCountry']); . 'Contact:' . cleanPosUrl($_POST['posContact']); . 'Actvity:' . cleanPosUrl($_POST['posActivity']); . 'Comments:' . cleanPosUrl($_POST['posComments']); 


$headers = "From: ".cleanPosUrl($_POST['posName'])." <".cleanPosUrl($_POST['posEmail']).">\r\n";
$headers .= 'To: '.$yourName.' <'.$yourEmail.'>'."\r\n";
$mailit = mail($to,$subject,$message,$headers);

Link to comment
https://forums.phpfreaks.com/topic/113074-small-syntax-problem-i-cant-solve/
Share on other sites

Here's one way to write it:

<?php
$msg_flds = array('Name','Email','Staying','Country','Contact','Activity','Comments');
$tmp = array();
$tmp[] = 'Cape Town Alive - Cape Xtreme Booking Request';
foreach($msg_flds as $fld)
     $tmp[] = $fld . ': ' . cleanPosUrl($_POST['pos' . $fld]);
$message = implode("<br>\r\n",$tmp);
$tmp = array();
$tmp[] = "From: ".cleanPosUrl($_POST['posName'])." <".cleanPosUrl($_POST['posEmail']).">";
$tmp[] = "To: $yourName <$yourEmail>";
$headers = implode("\r\n",$tmp);

$mailit = mail($to,$subject,$message,$headers);
?>

 

Ken

'Cape Town Alive - Cape Xtreme Booking Request' <br> 'Name:'

There are a few problems with this,

1. The string(s) isn't/aren't enclosed properly

2. HTML in an e-mail message isn't generally going to work unless you specify that the e-mail is HTML-formatted

3. There are extra semi-colons which need to be removed

 

A solution would be something like:

"Cape Town Alive - Cape Xtreme Booking Request\nName:"

Assuming that your MTA auto-converts \n to \r\n, which may be a bad assumption...

Thanks Ken, using your solution there and it works perfectly.

 

Im also puzzling on how to make it send this mail to 2 recipients... at the moment its just the one...

As in, support@ and to support2@

Here is another extract..

 

Thanks again,

Chris

 


$yourName = 'Cape-Town-Alive';
$yourEmail = '[email protected]';
$yourSubject = 'New booking request';

        $to = $yourName;
        $subject = 'New Booking Request: '.cleanPosUrl($_POST['posActivity']);

$msg_flds = array('Name','Email','Staying','Country','Contact','Activity','Text');
$tmp = array();
$tmp[] = 'Cape Town Alive - Cape Xtreme Booking Request';
foreach($msg_flds as $fld)
     $tmp[] = $fld . ': ' . cleanPosUrl($_POST['pos' . $fld]);
$message = implode("\r\n",$tmp);
$tmp = array();
$tmp[] = "From: ".cleanPosUrl($_POST['posName'])." <".cleanPosUrl($_POST['posEmail']).">";
$tmp[] = "To: $yourName <$yourEmail>";
$headers = implode("\r\n",$tmp);
        $mailit = mail($to,$subject,$message,$headers);

Sending to multiple recipients is the same as when you send regular e-mail, just put a comma between the addresses, e.g. "Person A" <[email protected]>, "Person B" <[email protected]>. Or you can use CC and BCC headers if that's what you're after.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.