0

I have a problem with sending emails via my domain. I have created a homepage with a input field and when you enter a valid email, my domain mail should send an email to the entered mail address.

I'm using phpmailer to do this, but for some reason these mails ending up as junk for outlook and hotmails. (It works fine with Gmail)

Have read alot stack posts about this problem, but haven't solved it yet. Have tried edit the From, Sender, ApplyTo, AddApplyTo and you name it. None seemed to work yet.

Script:

try {
    $mail = new PHPMailer(true);

    $mail->IsSMTP();
    $mail->Host       = "smtp.unoeuro.com";

    $mail->From       = "from_mail@domain.com";
    $mail->Sender = 'no-reply@domain.com';

    $mail->setFrom('from_mail@domain.com', 'Name');
    $mail->addReplyTo($_POST['email'], 'Name');

    $mail->SMTPAuth   = true;                  
    $mail->SMTPSecure = "tls";                 
    $mail->Port       = 25;                   
    $mail->Username   = "no-reply@domain.com";  
    $mail->Password   = "password removed";      

    $mail->Subject    = "Thanks for your interest!";

    $mail->IsHTML(true);

    $mail->Body='Thanks for your interest';

    $address = $_POST['email'];
    $mail->AddAddress($address, "Express");

    $mail->Send();

    }catch (phpmailerException $e) {
        echo $e->errorMessage();
    } catch (Exception $e) {
        echo $e->getMessage();
}

Is there something wrong here in this script that can cause the problem?

Ray
  • 75
  • 9
  • Do you control the `express.com` domain? – tadman Apr 12 '17 at 22:27
  • No, its just an example :) I have removed my domain name. Have edited so there is no confusion. – Ray Apr 12 '17 at 22:29
  • Use `example.com` for something like that, but be aware you *do* need to have SPF properly configured for whatever domain you're sending from or your mail *will* get junked as fraudulent. – tadman Apr 12 '17 at 22:30
  • Is your ipaddress whitelisted in the spf txt record? – Forbs Apr 12 '17 at 22:31
  • I start looking into SPF :) – Ray Apr 12 '17 at 22:32
  • Looked and added SPF via my domain hotel, but it did not help, still sending to junk folder. (I have waited the 24 hours i should for the DNS to update, but it does not work) – Ray Apr 14 '17 at 19:59

0 Answers0