6
votes

I am trying to send an email in following way -

from : [email protected]  
reply-to : [email protected]  
to : [email protected]  
cc : [email protected]  

My email is getting delivered to the address mentioned in CC (If I replace the emails to and cc, then email is sent to the address mentioned in to)

For some reason, email is not getting delivered to the address [email protected]. If I send the email manually to this address using outlook or gmail, then email is actually delivered. How can I debug this issue ?

I checked spam/junk directories as well, no emails over there. I tried using php mail() function as well as phpmailer class. Both of them return TRUE. What could the reason ? Please help.

$mail->From = "[email protected]";   
$mail->AddReplyTo("[email protected]");  
$mail->AddAddress("[email protected]");  
$mail->AddCC("[email protected]");  
$mail->Subject = $subject;  
$mail->Body = $message;  

if(! $mail->Send()) {  
    echo "Message was not sent";  
    echo "Mailer Error: " . $mail->ErrorInfo;  
    exit; 
} 
3
Please give your code you tried - Elby
AFAIK, PHP's mail () doesn't have a solid debug mechanism. So you can't know for sure where the problem lies. - asprin
Yes. Thats why, I used phpmailer class. It also returns true. Doesn't throw any error. I have added code to the question above. - Aniruddha Shival
My bad, didn't see that you were using PHPMailer. Also sometimes it does happen that the email reaches after a long time. I've had emails reaching me 30-40 mins after I ran the code. - asprin
I have been testing the functionality for 3-4 Hrs now. Haven't received any email so far. - Aniruddha Shival

3 Answers

2
votes
Try to set cofigurations beffore send (Gmail config):



    $mail = new Mailer();
    $mail->SMTPDebug = true;
    $mail->SMTPAuth = true;
    $mail->CharSet = 'utf-8';
    $mail->SMTPSecure = 'ssl';
    $mail->Host = 'smtp.gmail.com';
    $mail->Port = '465';
    $mail->Username = 'your login here';
    $mail->Password = 'your password here';
    $mail->Mailer = 'smtp';
    $mail->From = 'form mail address';
    $mail->FromName = 'from name';
    $mail->Sender = 'form mail';
    $mail->Priority = 3;

    $mail->AddAddress('mail', 'admin name');
    $mail->AddReplyTo('replay to', 'admin name');
    $mail->Subject = 'subject';
    $mail->Body = 'some HTML message here';
    $mail->IsHTML(true);
    if(!$this->Send()) {
        print_r('error: '. $mail->ErrorInfo); // Show errors   
 }
    $mail->ClearAddresses();
    $mail->ClearAttachments();
0
votes

check that your server is aloud to send emails the same happened to me in my case i used plesk and for some reason I was not able to send and email until I receive and email I change this configuration and worked check also is you use send mail o qmail if is qmail you have to tell php mailer

0
votes

This can also happen if you are sending email from one email address, but authenticating it against a different one (or domain)

Set $mail.setFrom() to the same email for which you are authenticating against.