Am trying to send mail to 3 gmail recipient account. The codes runs but could not send mail to any of the account. am using xammp server. can someone tell me what is wrong
Thanks
Code:<?php if(!isset($_POST['submit'])) { echo "error; you need to submit the form!"; } $name = $_POST['name']; $visitor_email = $_POST['email']; $message = $_POST['message']; //Validate first if(empty($name)||empty($visitor_email)) { echo "Name and email are mandatory!"; exit; } if(IsInjected($visitor_email)) { echo "Bad email value!"; exit; } require('pdo_db.php'); $result = $db->prepare('SELECT * FROM email_list order by id asc'); $result->execute(array()); while ($row = $result->fetch()) { $addresses[]=$row['email']; } $email_from = 'me@gmail.com';//<== update the email address $email_subject = "New Form submission"; $email_body = "You have received a new message from the user $name.\n". "Here is the message:\n $message". $headers = "From: $email_from \r\n"; $headers .= "Reply-To: $visitor_email \r\n"; //Send the email! $to = implode(", ", $addresses); mail($to,$email_subject,$email_body,$headers); //echo $to; header('Location: thanks.html'); // Function to validate against any email injection attempts function IsInjected($str) { $injections = array('(\n+)', '(\r+)', '(\t+)', '(%0A+)', '(%0D+)', '(%08+)', '(%09+)' ); $inject = join('|', $injections); $inject = "/$inject/i"; if(preg_match($inject,$str)) { return true; } else { return false; } } ?>



Reply With Quote

Bookmarks