PHP邮件()形式发送到GMAIL垃圾邮件 [英] PHP mail() form sending to GMAIL spam

查看:127
本文介绍了PHP邮件()形式发送到GMAIL垃圾邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这个问题已经在这里解决了几次。我试着按照指示设置正确的标题,我仍遇到我的电子邮件进入Gmail中的垃圾邮件过滤器的问题。



如果有人可以请看看我试过的东西,我真的很感激它。下面的代码没有添加头文件,如下所述: http://www.velvetblues.com/web-development-blog/avoid-spam-filters-with-php-mail-emails/



  define(WEBMASTER_EMAIL,'myName@mydomain.com'); 
if($ post)
{
$ name = stripslashes($ _ POST ['name']);
$ email = trim($ _ POST ['email']);
$ subject = trim($ _ POST ['subject']);
$ message = stripslashes($ _ POST ['message']);

$ error ='';

//检查名称
if(!$ name)
$ error。='需要名称! ;

//检查电子邮件
if(!$ email)
$ error。='需要电子邮件! ;

if($ email&&!ValidateEmail($ email))
$ error。='电子邮件地址无效! ;

//检查信息
if(!$ message)
$ error。=请输入您的信息!;
$ b $ if if(!$ error)
{

$ mail = mail(WEBMASTER_EMAIL,$ subject,$ message,
From:。$姓名。<。$ email。> \r\\\

。回复:。$ email。\r\\\

。X -Mailer:PHP /。phpversion());

if($ mail)
echo'OK';
}
else
echo'< div class =errormsg>'。$ error。'< / div>';


解决方案

使用此代码

  $ to = Email; 
$ subject = subject;
$ body =< div> hi hi ..< / div>;

$ headers ='From:YourLogoName info@domain.com'。 \r\\\
;
$ headers。='回复:'。 $ to。 \r\\\
;
$ headers。='X-Mailer:PHP /'。 phpversion();
$ headers。=MIME-Version:1.0 \r\\\
;
$ headers。=Content-type:text / html; charset = iso-8859-1 \r\\\
;
if(mail($ to,$ subject,$ body,$ headers)){
echo('< br>'。Email Sent; D。'< / br>') ;
}
else
{
echo(< p>电子邮件消息传递失败...< / p>);
}


I know this problem has been addressed a few times on here. I tried following the directions for setting proper headers, I still run into problems with my emails going into the spam filter in Gmail.

If anyone can please take a look at what I've tried, I'd really appreciate it. The code below is without the headers added as explained here: http://www.velvetblues.com/web-development-blog/avoid-spam-filters-with-php-mail-emails/

Thanks in advance.

define("WEBMASTER_EMAIL", 'myName@mydomain.com');
if($post)
{
    $name    = stripslashes($_POST['name']);
    $email   = trim($_POST['email']);
    $subject = trim($_POST['subject']);
    $message = stripslashes($_POST['message']);

    $error = '';

    // Check name
    if(!$name)
        $error .= 'Name required! ';

    // Check email
    if(!$email)
        $error .= 'E-mail required! ';

    if($email && !ValidateEmail($email))
        $error .= 'E-mail address is not valid! ';

    // Check message
    if(!$message)
        $error .= "Please enter your message!";

    if(!$error)
    {

        $mail = mail(WEBMASTER_EMAIL, $subject, $message,
            "From: ".$name." <".$email.">\r\n"
            ."Reply-To: ".$email."\r\n"
            ."X-Mailer: PHP/" . phpversion());

        if($mail)
            echo 'OK';
    }
    else
        echo '<div class="errormsg">'.$error.'</div>';
}

解决方案

Use this code :

 $to = Email;
 $subject = subject ;
 $body = "<div> hi hi .. </div>";

    $headers = 'From: YourLogoName info@domain.com' . "\r\n" ;
    $headers .='Reply-To: '. $to . "\r\n" ;
    $headers .='X-Mailer: PHP/' . phpversion();
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";   
if(mail($to, $subject, $body,$headers)) {
  echo('<br>'."Email Sent ;D ".'</br>');
  } 
  else 
  {
  echo("<p>Email Message delivery failed...</p>");
  }

这篇关于PHP邮件()形式发送到GMAIL垃圾邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆