dszsajhd237437 2015-05-21 18:28
浏览 18

Php邮件。 无法通过一个地址收到电子邮件

I have a problem with my mail in php. I code form to send email. I receive email on gmail but I have other mail address and I can't get email on it. I checked in spam and there is no email also. Below is my code.

<?php
$emailErr =  "";
$endMessage = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["email"])) {
$emailErr = "Proszę uzupełnić pole e-mail";
} 
else if (isset($_REQUEST['email']))
//if "email" is filled out, send email
{
//send email
$namesurname = $_REQUEST['name_surname'] ;
$email = $_REQUEST['email'] ;
$number = $_REQUEST['number'] ;
$subject = $_REQUEST['subject'] ;
$message = $_REQUEST['message'] ;
$message = $subject . ": " . $message . " " . $number . " " . $namesurname .     " " . $email;
$subject = "=?UTF-8?B?".base64_encode($subject)."?="; 
mail("szafor@szafor.pl", "Zamówienie pomiaru", 
$message, "From: formularz@szafortest.pl 
"."Content-Type: text/plain;     charset=UTF-8
"); 
$endMessage = "Dziękuję za przesłanie wiadomości.";
}
}
?>
  • 写回答

1条回答 默认 最新

  • dongwen7380 2015-05-21 20:00
    关注

    One important thing to consider with sending mail is that you should at least have the return path of the message be an email address that is actually hosted on the server that you are sending from.

    You can set the From and the Reply-To address as any address, but the return-path should be set to a valid email address hosted on your server. Let's say that you want the "reply" button to send back to "this_email@wherever.com" but the server you are using hosts email for "mydomain.com". Create an email account on your server, "info@mydomain.com" for example.

    $recipient = "sendto@email.com";
    
    $subject = "Test email";
    
    $message = "This is the message.";
    
    $headers .= "From: Your Name Here <any_email@wherever.com>
    ";
    $headers .= "Reply-To: Your Name Here <any_email@wherever.com>
    ";
    $headers .= "Return-Path: Your Name Here <info@mydomain.com>
    ";
    $headers .= "Content-Type: text/plain; charset=UTF-8
    ";
    $headers .="X-Mailer: PHP/" . phpversion() . "
    ";
    $headers .="MIME-Version: 1.0
    ";
    
    mail($recipient, $subject, $message, $headers);
    

    I have found that the more valid header information that I provide, the more likely the email will be delivered. Right now these headers always work for me, and I have a scheduling program that is sending email to a hundred different email addresses every day. See if that works better for you.

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度