0

I have a simple website set up on godaddy, decided to add emails straight to me instead of through godaddy, started using the phpmailer and I only receive emails from users submitting on my website form if they send an email with gmail. All other emails get ignored. Wonder if it's a godaddy issue.

$connect = mysqli_connect('localhost', 'pf', '*********', 'bs-portf'); 

if(mysqli_connect_errno()){
    echo "Failed to connect" . mysqli_connect_error();

}

   if(mysqli_ping($connect)){
       // echo "we are connected";

   }else{
       echo "Error: ". mysqli_error($connect);
       die("Connection failed");
   }
?>
<?php

if(isset($_POST['submit'])){

require 'phpmailer/PHPMailerAutoload.php';
$mail = new PHPmailer();

$name = $_POST['name'];
$email = $_POST['email'];
$message = nl2br($_POST['message']);  //nl2br() new lines in text message to break tags

$mail->Host='smtp.gmail.com';
// $mail->isSMTP();
$mail->Port=465; 
$mail->SMTPAuth=true;
$mail->SMTPsecure='ssl'; 
$mail->Username='bradv@gmail.com';
$mail->Password='**********';

$mail->setFrom($email, $name);
$mail->addAddress('bradv@gmail.com');
$mail->addReplyTo('info@example.com', 'Information');

$mail->isHTML(true);
$mail->Subject='Form Submission';
$mail->Body= "test email body 1";
// $mail->Body='<p align=center>Name :'.$name. '<br>Email: '.$email. 
'<br>Message '.$message. '</p>';
// echo "submit worked";

if($mail->send()){
    echo 'mail is sent';
    // $result ="Something went wrong. Please try again.";
}else{
    echo 'email failed';
    // $result="Thanks " .$name. " for contacting us. We'll get back to you 
soon!";
}
Brad Vanderbush
  • 173
  • 1
  • 13
  • Don't set a fake sender in the `From:` field `$mail->setFrom($email, $name);` then. See also [PHP mail function doesn't complete sending of e-mail](//stackoverflow.com/q/24644436) – mario Nov 01 '18 at 01:35
  • That post is from 2008.. is that even still legit? – Brad Vanderbush Nov 01 '18 at 02:18

1 Answers1

1

Check the spam folder. If you send an email using one address as login but sets the From address as another, Gmail will think its spam.

Set from address with the same email as the login and replyto as the user's email.