I am rather green with PHP and am trying to use the PHPMailer some of you may be familiar with found on Github https://github.com/PHPMailer
I am having a strange issue. My PHP Mailer only succeeds if accessed through Firefox. Chrome and Safari are a no go. Anyone who could give it a look over, it would be much appreciated!!
Here is the HTML snippet for the form:
<div class="col-2-third col-last">
<div id="contact-form-result" data-notify-type="success" data-notify-msg="<i class=icon-ok-sign></i> Message Sent Successfully!"></div>
<form class="no-b-margin" id="template-contactform" name="template-contactform" action="include/sendemail.php" method="post">
<div class="form-process"></div>
<div class="col-1-half">
<input type="text" id="template-contactform-name" name="template-contactform-name" value="" class="sm-form-control required" placeholder="Name">
</div>
<div class="col-1-half col-last">
<input type="email" id="template-contactform-email" name="template-contactform-email" value="" class="required email sm-form-control" placeholder="Email"/>
</div>
<div class="clear"></div>
<div class="col-full col-last">
<input type="text" id="template-contactform-website" name="template-contactform-website" value="" class="sm-form-control" placeholder="Website">
</div>
<div class="clear"></div>
<div class="col-full">
<textarea class="required sm-form-control" id="template-contactform-message" name="template-contactform-message" rows="6" cols="30" placeholder="Message"></textarea>
</div>
<div class="clear"></div>
<div class="col-full hidden">
<input type="text" id="template-contactform-botcheck" name="template-contactform-botcheck" value="" class="sm-form-control">
</div>
<div class="clear"></div>
<div class="col-full">
<button class="button button-border button-reveal fright tright nomargin" type="submit" id="template-contactform-submit" name="template-contactform-submit" value="submit"><i class="fa fa-paper-plane"></i><span>Send Message</span></button>
</div>
<div class="clear"></div>
</form>
</div>
and here is the php code:
<?php
require_once('phpmailer/class.phpmailer.php');
$mail = new PHPMailer();
if( isset( $_POST['template-contactform-submit'] ) AND $_POST['template-contactform-submit'] == 'submit' ) {
if( $_POST['template-contactform-name'] != '' AND $_POST['template-contactform-email'] != '' AND $_POST['template-contactform-message'] != '' ) {
$name = $_POST['template-contactform-name'];
$email = $_POST['template-contactform-email'];
$website = $_POST['template-contactform-website'];
$message = $_POST['template-contactform-message'];
$subject = isset($subject) ? $subject : 'New Message From Contact Form';
$botcheck = $_POST['template-contactform-botcheck'];
$toemail = 'myemailremoved@gmail.com'; // Your Email Address
$toname = 'ryan'; // Your Name
if( $botcheck == '' ) {
$mail->SetFrom( $email , $name );
$mail->AddReplyTo( $email , $name );
$mail->AddAddress( $toemail , $toname );
$mail->Subject = $subject;
$name = isset($name) ? "Name: $name<br><br>" : '';
$email = isset($email) ? "Email: $email<br><br>" : '';
$website = isset($website) ? "Website: $website<br><br>" : '';
$message = isset($message) ? "Message: $message<br><br>" : '';
$referrer = $_SERVER['HTTP_REFERER'] ? '<br><br><br>This Form was submitted from: ' . $_SERVER['HTTP_REFERER'] : '';
$body = "$name $email $website $message $referrer";
$mail->MsgHTML( $body );
$sendEmail = $mail->Send();
if( $sendEmail == true ):
echo 'We have <strong>successfully</strong> received your Message and will get Back to you as soon as possible.';
else:
echo 'Email <strong>could not</strong> be sent due to some Unexpected Error. Please Try Again later.<br /><br /><strong>Reason:</strong><br />' . $mail->ErrorInfo . '';
endif;
} else {
echo 'Bot <strong>Detected</strong>.! Clean yourself Botster.!';
}
} else {
echo 'Please <strong>Fill up</strong> all the Fields and Try Again.';
}
} else {
echo 'An <strong>unexpected error</strong> occured. Please Try Again later.';
}
?>