html5 - PHP emails not sending -
been trying working , sending email website emails aren't coming through.
it easy. blocked actual sending email (for both areas)
thanks help!
my php code in index.php
<?php $field_name = $_post['name']; $field_email = $_post['email']; $field_message = $_post['message']; ini_set("smtp","ssl://smtp.gmail.com"); ini_set("smtp_port","465"); $mail_to = 'coverupemail@email.com'; $subject = 'message portfolio visitor '.$field_name; $body_message = 'from: '.$field_name."\n"; $body_message .= 'e-mail: '.$field_email."\n"; $body_message .= 'message: '.$field_message; $headers = 'from: '.$email."\r\n"; $headers .= 'reply-to: '.$email."\r\n"; $mail_status = mail($mail_to, $subject, $body_message, $headers); if ($mail_status) { ?> <script language="javascript" type="text/javascript"> alert('thank message.'); window.location = 'index.html'; </script> <?php } else { ?> <script language="javascript" type="text/javascript"> alert('message failed. please, send email manually coverupemail@email.com'); window.location = 'index.html'; </script> <?php } ?>
my html code linking index.php
<form method="post" action="index.php"> <p class="contact"> <input type="text" name="name" id="name" value="" size="22" /> <label for="name"><small>name (required)</small></label> </p> <p class="contact"> <input type="email" name="email" id="email" value="" size="22" /> <label for="email"><small>mail (required)</small></label> </p> <p class="contact"> <textarea name="message" id="message" value="" rows="10"></textarea> <label for="message"><small>message (required)</small></label> </p> <p class="contact"> <input id="submit" name="submit" type="submit" value="submit" /> <input name="reset" type="reset" id="reset" tabindex="5" value="reset form" /> </p> </form>
what $mail_status value ? if "1" not guarantee sending of mail :( depends upon server php returns 1 moment message handed on mail sending part of server.
cases 1 : if script running on server try sample code verify mail been sent create page mailtest.php following code
<?php mail("coverupemail@email.com","test msg","hello test message");?>
this verify yes working.
case 2 : if working on localhost u have have smtp server or mail server make easy can use gmail send via localhost ( did use gmail account )
also see link email sending
btw a. ini_set() think not used. b. window.location = 'index.html';
navigate index page wat if person navigates ? mail wud sent again maybe... wud suggest use
location.replace('index.html');
thx
Comments
Post a Comment