【问题标题】:PHP contact form is not sending if the user use an @yahoo domain如果用户使用@yahoo 域,则不会发送 PHP 联系表单
【发布时间】:2016-01-27 18:04:17
【问题描述】:

我只是注意到我们网站中的联系表存在问题,用户可能使用的任何电子邮件都可以正常工作,但如果用户使用@yahoo 邮件,则联系表不会发送信息。此外,联系表格会向发件人发送一份副本,电子邮件的副本会到达雅虎帐户。

我已经尝试使用我的一台服务器更改邮件标题,添加一个 Replay-To。(向那里发送用户邮件)以便用户可以毫无问题地相互写信。

但联系表单同样适用于除 yahoo 之外的任何域。

请修改我的代码,看看是否有问题。

<?php 

$_POST['Email'] = trim($_POST['Email']);
if($_POST['Email']=='test@ex.com'){
  //hwSessionSetVar('img_verify_skipped', 6);
  hwSessionSetVar('cInfo',$_POST['Name']."\n".$_POST['Email']."\n".$_POST['Phone']);
  die('Test Mode');
}
if($_POST['Name']=='' or $_POST['Email']=='' or $_POST['Phone']=='' or     $_POST['Message']=='' or !IsEmail($_POST['Email']))
{
echo '<script language="javascript" type="text/javascript">javascript:history.back(alert("Error: Favor de llenar todos los campos con la informacion correcta e intentarlo de nuevo"));</script>';
exit;
}
else {

require_once SITE_PATH.'modules/Captcha/class.image_verify.php';
$o_iv = new Image_Verify;
if(!$o_iv->IsTextOK(false,5)){ 
  echo '<script language="javascript" type="text/javascript">javascript:history.back(alert("'.hwLng('err_img_code').'"));</script>';
  exit;
}


//mysql_connect('localhost','alex_4email','Sys4Se') or die ('error de conexion'.mysql_error());
//mysql_select_db('alex_cl4');

$id_cc = (int)$_POST['id_cc'];
list($uid,$l_title,$l_descr,$l_price,$l_email) = $db->one_row("SELECT userid,v_title,v_descr,v_price,hw_email FROM ".TBL_AD." WHERE link_id=".$id_cc);
if(!$uid) die('Access Denied');

list($to,$cc,$en_ad_email) = $db->one_row("SELECT email,email_2,hw_en_ad_email FROM ".TBL_USER." WHERE id=".$uid);

if($en_ad_email && IsEmail($l_email)){
  $to = $l_email;
  $cc = '';
}

//DIRECCIONES DE EMAIL PARA PRUEBAS
//$to = "" ;
//$cc = ""; 
//$cc = ""; 
$ip = $_SERVER['REMOTE_ADDR'];
$ad_url = 'http://clasificadoscontacto.com/'.hwGetAdURL($id_cc);//index.php?page=out&id='.$id_cc;
if(EN_SE_ADV) hwProcessTags($ad_url);

/****************CONSTRUYE EMAIL AVISA  A CLIENTE*****************************/
$s1_to=$to; //cuenta destino
$s1_subject="Solicitud de informacion en www.clasificadoscontacto.com"; //subject
$s1_html='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 //mensaje

//para el envo en formato HTML
//direccin del remitente

if(strpos($_REQUEST['Name'],"\n")!==false) die('Access Denied');

$s1_headers = 'From: postmaster@clasificadoscontacto.com' . "\r\n" .
          "Reply-To:".$_REQUEST['Name']." <".$_REQUEST['Email']."> \r\n";
$s1_headers .= "MIME-Version: 1.0\r\n";
$s1_headers .= "Content-type: text/html\r\n";


/****************CONSTRUYE EMAIL CC  A CLIENTE*****************************/
        $s2_tocc=$cc; //cuenta destino

        //direccin del remitente
        $s2_headers = "From: noreply@clasificadoscontacto.com \r\n";
        $s2_headers .= "MIME-Version: 1.0\r\n";
        $s2_headers .= "Content-type: text/html\r\n";

    if ($cc!="")
    {   
        mail($s2_tocc,$s1_subject,$s1_html,$s2_headers);
//hwSendMail($s2_tocc,'noreply@clasificadoscontacto.com',$s1_subject,$s1_html);
    }
/****************CONSTRUYE EMAIL PARA CLASIFICADOS CONTACTO Y PERSONA QUE CONTACTA*****************************/
    $s_contacto="ayuda@clasificadoscontacto.com"; //cuenta destino
    $s_interesado=$_REQUEST['Email']; //cuenta destino
    $s_sub_contacto="www_contacto ".$to.", ".$cc;
    $s_sub_interesado="Copia de su solicitud en clasificadoscontacto.com"; //subject
    $s3_html='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 //mensaje
//para el envo en formato HTML

    mail($s_contacto,$s_sub_contacto,$s3_html,$s1_headers);
    //hwSendMail($s_contacto,$_REQUEST['Name']." <".$_REQUEST['Email'].">",$s_sub_contacto,$s3_html);
  mail($s_interesado,$s_sub_interesado,$s3_html,$s2_headers);
//hwSendMail($s_interesado,'noreply@clasificadoscontacto.com',$s_sub_interesado,$s3_html);

  $l_descr = trim(preg_replace('/\s+/',' ',strip_tags($l_descr)));
  $len = DESCR_MAX_LEN>0 ? DESCR_MAX_LEN : 253;
  if($len>253) $len = 253;
  if($len>0 && strlen($l_descr)>$len) $l_descr = substr($l_descr,0,$len).'..';

  $a_v = array('Email','Name','Phone','Message');
  foreach($a_v as $k) $_POST[$k] = $_POST[$k]!='' ? html_esc(trim(strip_tags($_POST[$k]))) : '';
  $db->query('INSERT INTO '.hwModTable('Form_to_Email','request').' SET lid='.$id_cc.',ts_added=UNIX_TIMESTAMP(),uid='.$uid.
    ',ip=?,email=?,name=?,phone=?,msg=?,l_title=?,l_descr=?,l_price=?', 
array($_SERVER['REMOTE_ADDR'],$_POST['Email'],$_POST['Name'],$_POST['Phone'],$_POST['Message'],$l_title,$l_descr,$l_price) );

/****************************************************************************/

               hwSessionSetVar('cInfo',$_POST['Name']."\n".$_POST['Email']."\n".$_POST['Phone']);

  if(mail($s1_to,$s1_subject,$s1_html,$s1_headers)){
  //if(hwSendMail($s1_to,$_REQUEST['Name']." <".$_REQUEST['Email'].">",$s1_subject,$s1_html)){
          header( "Location: index.php?page=envio_ok" );
      exit;
        }
        else{
           print "The email cannot be sent, favor de contactarte con : webmaster@clasificadoscontacto.com";
        }


}

因此,如果用户使用他的 yahoo 帐户,脚本总是会说:无法发送电子邮件。谢谢大家的热心回答。

【问题讨论】:

  • 你能把你的代码分解成相关的部分吗?
  • 寻求调试帮助的问题(“为什么这段代码不起作用?”)必须包括所需的行为、特定的问题或错误以及在问题本身中重现它所需的最短代码。没有明确问题陈述的问题对其他读者没有用处。请参阅:How to create a Minimal, Complete, and Verifiable example
  • HI Diddle Dot,我不知道什么与您相关?我的意思是为什么所有这些代码都适用于除雅虎以外的任何域。?构造 haeder 的部分是 this://para el envo en formato HTML //direccin del remitente if(strpos($_REQUEST['Name'],"\n")!==false) die('Access Denied '); $s1_headers = '来自:postmaster@clasificadoscontacto.com' 。 “\r\n”。 "回复:".$_REQUEST['Name']." \r\n"; $s1_headers .= "MIME 版本:1.0\r\n"; $s1_headers .= "内容类型:text/html\r\n";
  • @IsraelToxqui 如何验证电子邮件的任何部分,或者将代码发送到“无法发送电子邮件”的相关条件。您的电子邮件的整个标记,不是很相关。请修改您的问题,而不是难以阅读的 cmets。
  • 感谢 Dan08,我清理了不相关的 HTML。

标签: php forms email yahoo


【解决方案1】:

大家好,我想让您知道,联系表格最终适用于任何域。问题不是代码,不是雅虎,问题出在服务器上的垃圾邮件规则中,不知何故只阻止了雅虎。 ——

【讨论】:

    猜你喜欢
    • 2013-12-25
    • 1970-01-01
    • 2013-04-14
    • 2015-10-31
    • 1970-01-01
    • 1970-01-01
    • 2023-04-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多