illuz1on Posted July 3, 2008 Share Posted July 3, 2008 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); Quote Link to comment https://forums.phpfreaks.com/topic/113074-small-syntax-problem-i-cant-solve/ Share on other sites More sharing options...
DarkWater Posted July 3, 2008 Share Posted July 3, 2008 The line break: <br /> Needs to be in the ' ', not outside of them, and you need to remove the ; after every call to cleanPosUrl() except the very last one. Quote Link to comment https://forums.phpfreaks.com/topic/113074-small-syntax-problem-i-cant-solve/#findComment-580798 Share on other sites More sharing options...
kenrbnsn Posted July 3, 2008 Share Posted July 3, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/113074-small-syntax-problem-i-cant-solve/#findComment-580801 Share on other sites More sharing options...
TransmogriBenno Posted July 3, 2008 Share Posted July 3, 2008 '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... Quote Link to comment https://forums.phpfreaks.com/topic/113074-small-syntax-problem-i-cant-solve/#findComment-580803 Share on other sites More sharing options...
illuz1on Posted July 3, 2008 Author Share Posted July 3, 2008 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); Quote Link to comment https://forums.phpfreaks.com/topic/113074-small-syntax-problem-i-cant-solve/#findComment-580807 Share on other sites More sharing options...
TransmogriBenno Posted July 3, 2008 Share Posted July 3, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/113074-small-syntax-problem-i-cant-solve/#findComment-580811 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.