0

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();
halfer
  • 19,824
  • 17
  • 99
  • 186

1 Answers1

0

You are forging from addresses which will guarantee delivery failures to Yahoo. Put your own address in from and the submitter's address in reply-to, like this:

$mail->From = 'contact@iulianbesliu.ro';
$mail->addReplyTo($emailT, $nume);

Let PHPMailer handle the reply-to header, don't add it yourself.

It's also a good idea to make sure your own SPF and DKIM records are correct, and sign your messages with DKIM, especially for Yahoo.

Does your mail server really use authentication without encryption?

Synchro
  • 35,538
  • 15
  • 81
  • 104
  • Thank you, i've done what you have suggested, and it's doing the same thing .I'm not very good with this email thing, i allways used the php mail() function, but here doesn't work, and i've tried phpmailer. – Gorschi Adrian Aug 01 '15 at 18:46
  • And, it is a funny thing , that i send the email to contact@iulianbesliu.ro and then i transfer it to 2 other emails on gmail. (iulianbesliu@gmail.com and gorschiadrian@gmail.com). If the submited email is on gmail, the email appears in inbox, else it appears in spam . – Gorschi Adrian Aug 01 '15 at 18:52
  • PHPMailer's influence ends as soon as it leaves your server. You need to make sure that everything else related to your domain is good - for example SPF, DKIM, that your mail server hostname resolves forwards and backwards, that you're not triggering content-based spam filters, that you have a history of not sending spam, that you're not sharing IPs with spammers etc. The messages that go into spam folders will often have headers saying why, so view source on them to see why. – Synchro Aug 01 '15 at 18:59