0

I tested my PHPMailer script, but its only receiving emails from certain email addresses.

When I try putting another email address (A dummy address I created) inside the form, its not sending the email.

How do I make it receive emails from all addresses typed into the form

<?php

$result="";

if(isset($_POST['submit'])){
    require 'phpmailer/PHPMailerAutoload.php';
    $mail = new PHPMailer;

    $mail->Host='smtp.gmail.com';
    $mail->Port=587;
    $mail->SMTPAuth=true;
    $mail->SMPTSecure='tls';
    $mail->Username='jerrytesting12345@gmail.com';
    $mail->Password='******';

    $mail->setFrom($_POST['email'],$_POST['name']);
    $mail->addAddress('jerrytesting12345@gmail.com');
    $mail->addReplyTo($_POST['email'],$_POST['name']);

    $mail->isHTML(true);
    $mail->Subject='Bradas Contact: '.$_POST['subject'];
    $mail->Body='Message: '.$_POST['msg'].'</h1>';

    if(!$mail->send()){
        $result='something went wrong';
    } else {
        $result='thank you';
    }
}

?>

Jaromme Lawn
  • 53
  • 1
  • 7
  • Faking the From: address triggers all sorts of spam filtering. – mario Feb 20 '19 at 03:24
  • Obligatory reference: https://stackoverflow.com/questions/24644436/php-mail-function-doesnt-complete-sending-of-e-mail - also applicable to PHPMailer. – mario Feb 20 '19 at 03:25
  • Gmail doesn't let you forge from addresses anyway. Base your code on the [contact form](https://github.com/PHPMailer/PHPMailer/blob/master/examples/contactform.phps) and [gmail](https://github.com/PHPMailer/PHPMailer/blob/master/examples/gmail.phps) examples provided with PHPMailer. – Synchro Feb 20 '19 at 11:47

1 Answers1

0

Maybe it is going spam. Since you cannot send emails from others email addresses. You need to set "FROM" your domain e-mail, for example no-reply@yourdomain.com.

Vesla
  • 15
  • 5