douchen5971 2015-06-19 05:03
浏览 24
已采纳

php - Gmail不接受包含链接的电子邮件

I am using PHPmailer to send emails that contain activation codes to the people who have signed up on my website. Everything worked fine with Yahoo! but not with Gmail. There is no errors in my PHP script. Everything looked okay. I tried to remove all the links from the email text and replaced it with random string like 'rrrrrrr' and it worked, I received the mail in my mailbox. This only happens with Gmail. Does anyone knows how to overcome this problem? Also, I am hosting my website on hostinger.com but i am currently testing PHPmailer on localhost using wampserver

EDIT: my website is http://www.pascal-tweaks.esy.es/ I don't think that it looks like a spam link. I found my emails in the spam folder, but I must say that two days ago it was working fine with Gmail and I was receiving them in my mailbox. I thought maybe they recently decided to not trust links like that? I still want another solution because I don't want my website's users to bother going to the spam folder :(

Here is my code, $email_sent is always true :

$toemail = $_SESSION['toemail'];
$nom = $_SESSION['name'];
$email_color = $_SESSION['email_color'];
$email_theme = $_SESSION['email_theme'];
$index = $_SESSION['index'];
$code = $_SESSION['code'];

$smtphost = 'smtp.topnet.tn';
$smtpport = 25;


$dom = 'http://www.mydomain.esy.es';

$from = 'mydomain@support.com';
$fromname = 'mywebsite';
$subj = 'signing in';
$greating = 'Thank you for registering!';
$htmlbody = 
    '<!DOCTYPE html>
    <html>
        <head>
            <meta charset="utf-8"/>
            <title>' . $greating . '</title>
        </head>
        <body style="margin:0;padding:10px 0;">
            <div style="width:450px;height:450px;max-height:450px;border:1px solid ' . $email_color . ';border-radius:260px;background-image:url(\'' . $dom . '/cssjs/theme' . $email_theme . '.jpg\');background-size:cover;box-shadow:0 0 22px 2px ' . $email_color . ';margin:30px auto;overflow:hidden;">
                <div style="height:78px;max-height:78px;width:350px;color:' . $email_color . ';margin:60px auto 54px auto;text-align:center;font-family:\'Cordia New\', \'Aparajita\';text-shadow:1px 1px 4px gray;">
                    <div style="font-size:52px;height:52px;max-height:52px;"><a style="text-decoration:none;color:' . $email_color . ';" href="' . $dom . '" target="_blank">My WebSite Name</a></div>
                    <div style="font-size:26px;height:26px;max-height:26px;">Welcome to my website!</div>
                </div>
                <div style="text-shadow:0 0 1px gray;background-image:url(\'' . $dom . '/cssjs/t_white.png\');width:429;height:238px;border-radius:8px 8px 260px 260px;padding:10px;font-family:\'Cordia New\', \'Aparajita\';">
                    <div style="margin:15px auto;font-size:22px;line-height:22px;text-align:center;width:400px;">' . $greating . ' <br/>' . $nom . ' !</div>
                    <div style="margin:15px auto;font-size:19px;line-height:19px;text-align:center;width:400px;">In order to activate your account, you must follow this link : <a href="' . $dom . '/activate.php?d=' . $index . '" target="_blank">' . $dom . '/activate_account</a><br/>Your activation code :<br/>' . $code . '</div>
                </div>
            </div>
        </body>
    </html>';
$altbody =  $greating . ' ' . $nom . ' !' . "
" .
            'In order to activate your account, you must follow this link  :' . "
" .
            'Activation link : ' . $dom . '/activate.php?d=' . $index . "
" .
            'Activation code : ' . $code;

require_once ($webdir . '/PHPMailer-master/PHPMailerAutoload.php');
$activation_mail = new PHPMailer;

$activation_mail->isSMTP();
$activation_mail->Host = $smtphost;
$activation_mail->Port = $smtpport;

$activation_mail->From = $from;
$activation_mail->FromName = $fromname;
$activation_mail->SetFrom($from, $fromname);
$activation_mail->addAddress($toemail);
$activation_mail->addReplyTo($from, $fromname);
$activation_mail->isHTML(true);
$activation_mail->CharSet = 'UTF-8';

$activation_mail->Subject = $subj;
$activation_mail->Body = $htmlbody;
$activation_mail->AltBody = $altbody;

if($activation_mail->send()){
    $email_sent = true;
}
else{
    $email_sent = false;
}
  • 写回答

1条回答 默认 最新

  • drbuowqe02101 2015-06-19 05:35
    关注

    1.) Your website http://www.pascal-tweaks.esy.es/ is hosted on free domain provider..I think this is one of the reason for receiving mail in the spam folder.. 2.) try this when you post your site on facebook wall or you message anybody it ll ask you about the security check or captcha.. So perhaps because of that gmail does not show link .. thanks..

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 准备学习小程序搭建,谁能手把手的教我啊?
  • ¥15 关于#嵌入式硬件#的问题:树莓派第一天重装配置python和opencv后第二天打开就成这样,瞎捣鼓搞出来文件夹还是没把原来的界面调回来
  • ¥20 Arduino 循迹小车程序电路出错故障求解
  • ¥20 Arduino 循迹小车程序电路出错故障求解
  • ¥100 AT89C52单片机C语言调试之后再回答
  • ¥15 AT89C52单片机C语言串口助手发送数据包返回值
  • ¥15 C++数组中找第二小的数字程序纠错
  • ¥50 MATLAB APP 制作出现问题
  • ¥15 wannier复现图像时berry曲率极值点与高对称点严重偏移
  • ¥15 利用决策森林为什么会出现这样·的问题(关键词-情感分析)