I am ussing the PHPMailer with SMTP authentication. The mail is sending only if the completed mail from form it is from Gmail.
I am taking the postst from a contact page, $nume = firstName, $prenume = last-name, $telefon = phone, $email = email, $mesaj = message (translated)
.
If completed mail (from form submission) is a Yahoo mail, everything goes to spam. If a Gmail, the first mail goes to imbox, the response goes to spam.
This is the code:
$nume = $_POST['nume'];
$prenume = $_POST['prenume'];
$telefon = $_POST['telefon'];
$emailT = $_POST['email'];
$mesaj = $_POST['mesaj'];
$mail = new PHPMailer;
$mail->isSMTP();
$mail->Host = 'mail.iulianbesliu.ro';
$mail->SMTPAuth = true;
$mail->Username = 'contact@iulianbesliu.ro';
$mail->Password = 'password';
$mail->Port = 25;
$mail->From = $emailT;
$mail->FromName = $nume;
$mail->addAddress('contact@iulianbesliu.ro');
$mail->AddCustomHeader('Reply-to:info@xpal.com');
$mail->Subject = 'Utilizator Site';
$mail->Body = 'Nume: ' . $nume . ' ' . ' Data Eveniment: ' . $prenume . ' ' . 'telefon: ' . $telefon . "\r\n" . $mesaj;
if(!$mail->send()) {
?>
<script>
alertify.error("Message could not be sent.");
</script>
<?php
//echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
?>
<script>
alertify.success("Message has been sent");
</script>
<?php
}
$responseMail = new PHPMailer;
$responseMail->isSMTP();
$responseMail->Host = 'mail.iulianbesliu.ro';
$responseMail->SMTPAuth = true;
$responseMail->Username = 'contact@iulianbesliu.ro';
$responseMail->Password = 'password';
$responseMail->Port = 25;
$responseMail->From = 'contact@iulianbesliu.ro';
$responseMail->FromName = 'Iulian Besliu';
$responseMail->addAddress($emailT);
$responseMail->AddCustomHeader('Reply-to:info@xpal.com');
$responseMail->Subject = 'Utilizator Site';
$responseMail->Body = 'Buna ziua dl/dna ' . $nume . "\r\n" . 'Va multumim pentru interesul acordat in vizualizarea paginii noastre, mesajul dumneavoastra a fost inregistrat si vom revenii cu un raspuns in cel mai scurt timp posibil !' . "\r\n" . 'Toate cele bune,' . "\r\n" . 'Iulian B`enter code here`esliu';
$responseMail->send();