0

伙计们,我有这个 php 代码:

$emailTo = 'proyectogoyapatrimonio@gmail.com';
$subject = "Firma // Salvemos el Goya";
$name=$_REQUEST['nombre'];
$apellido=$_POST['apellido'];
$dni=$_POST['dni'];
$email=$_POST['mail'];
$msg=$_POST['msg'];

$ask = "INSERT INTO firmas(nombre,apellido,dni,email,created_at) VALUES('".htmlentities($name)."','".htmlentities($apellido)."','".$dni."','".$email."','".date("Y-m-d H:i:s")."')";
if(mysql_query($ask,$conn)){
    $body = "<html>\n";
    $body .="<head></head>\n";
    $body .="<body>\n";
    $body .="<h4>Firma ProyectoGoya</h4><br/>\n";
    $body .="<h5>Datos:</h5>\n";
    $body .="<b>Nombre Completo:</b> ".$name." ".$apellido." <br/>\n";
    $body .="<b>E-mail:</b> ".$email." <br/>\n";
    $body .="<b>DNI:</b> ".$dni." <br/>\n";
    $body .="</body>\n";
    $body .= "</html>\n";

    $headers = "From: \"".$name."\" <$email>\n";
    $headers .= "To: \"Proyecto Goya\" <".$emailTo.">\n";
    $headers .= "Return-Path: <".$email.">\n";
    $headers .= "MIME-Version: 1.0\n";
    $headers .= "Content-Type: text/HTML; charset=ISO-8859-1\n"; 

    echo $headers."<br/>";

    mail($emailTo, $subject, $body, $headers);
}else{
    echo "Imposible salvar registro en DB.\n Intente nuevamente. \n Si el error persiste, contacte al proovedor del servicio.";
}   

现在,问题是,当我向这个 php 发送一个包含所有变量的 POST 请求时,我收到了这个错误:

Warning: mail() [function.mail]: SMTP server response: 554 Debe utilizar como remitente una cuenta de correo v�lida. in \\hmfsw\web\DTC001\proyectogoya.org\public_html\send.php on line 36

我回应了 $headers,我得到了这个:

From: "Pablo" To: "Proyecto Goya" Return-Path: MIME-Version: 1.0Content-Type: text/HTML; charset=ISO-8859-1

如您所见,我没有收到标题上打印的“发件人”电子邮件。知道为什么会发生这种情况吗?

谢谢!

4

1 回答 1

0

让你的代码更好:

确保您发送的电子邮件具有标题和转换器返回路径。

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'Return-Receipt-To: '.$email.'\r\n'; 

$headers .= 'To: Proyecto Goya <'.$emailTo.'>\r\n';
$headers .= 'From: '.$name.' <'.$email.'>' . '\r\n';

对于错误 554,尝试更改 php.ini 文件:

[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25

; For Win32 only.
;sendmail_from = admin@localhost

或者试试

[mail function]
; For Win32 only.
SMTP = smtp.srv.net
smtp_port = 25

; For Win32 only.
;sendmail_from = from@srv.net
于 2013-02-28T18:31:44.300 回答