简体   繁体   中英

Confirmation email goes into spam not in inbox

I am working on PHP Signup page with sending email for account verification using SMTP Gmail. My email goes to spam but I want them in the inbox, not in spam. Here is my code SMTP.php file

<?php
include "class.phpmailer.php"; // include the class name
$query1="select * from user";
$res = $conn->query($query1);

function mail_send($to,$user_id,$from="mbtc.neha123@gmail.com")
{
    $mail = new PHPMailer(); // create a new object
    $mail->IsSMTP(); // enable SMTP
    $mail->SMTPDebug=1; // debugging: 1 = errors and messages, 2 = messages only
    $mail->SMTPAuth=true; // authentication enabled
    $mail->SMTPSecure='ssl'; // secure transfer enabled REQUIRED for GMail
    $mail->Host="smtp.gmail.com";
    $mail->Port=465; // or 587, 465
    $mail->IsHTML(true);
    $mail->Username ="youremail";
    $mail->Password ="yourpassword";
    $mail->SetFrom($from,"YourCoin");
    $mail->Subject = "Verify your Account for YourCoin";
    $mail->Body = "<b>Hi,$to<br/>
<br/>You have Sucessfully Registered.Please Click this Link for verification 

<a href='http://yourcoin.me/verify_reg.php?
do=verify&user_id=$user_id'>http://yourcoin.me/verify_reg.php?
user_id=$user_id/</a></b>";
    $mail->AddAddress($to);
    $mail->CreateHeader();  
    if(!$mail->Send()){
        echo "Mailer Error: " . $mail->ErrorInfo;
    }
    else
    {
        //echo "Message has been sent";
        return true;
    }
}
?>

Please check the code & help me to get this correct. Thanks & regards Neha

There isn't anything "technically wrong" here and, what is "spam" to one mail account might be "ok" to another, it largely depends on which antispam and user's profile/preferences too...

That's said, i'd try the most obvious check:

1) Change the mail subject

2) Adding some more descriptive text to the body

3) Are you sure you really need to use HTML? The same can be achived in plain text, i'd give it a try.

4) Try sending the confirmation code avoiding the direct link into mail's body

5) Add some sort sort of fallback for users who wouldn't be able to click on the link, something like: "If the direct link doesn't work on your mail client, copy and paste it directly in your browser's location" (or something similar)

6) Add infos in case the mail would be delivered by accident to the wrong address "If you didn't request any registration... bla bla bla"

7) Check in mail header if ever the antispam added few lines of explication on why it has been considered as "spam".

I have to say, i am not surprised that your mails ended up in spam folder, considering the topic/subject/text I would have spotted as "spam" myself.

Hope it helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM