简体   繁体   English

PHP Mail,其中某些电子邮件未收到该电子邮件

[英]PHP Mail where the email isn’t being received on a certain email

I have my clients server – let's call it clientserver.com . 我有我的客户服务器-称它为clientserver.com

Emails sent from the server using the PHP mail function don't get received by an email account on that server – let's call it email@clientserver.com . 使用PHP mail功能从服务器发送的mail不会被该服务器上的电子邮件帐户接收,我们将其email@clientserver.com However, if I set the email ID to my own personal one it is received without any problem. 但是,如果我将电子邮件ID设置为自己的电子邮件ID,则不会出现任何问题。

Is there anything you guys can see that I could possibly add to the headers or anything else to ensure that this email@clientserver.com address receives the contact form email? 你们能看到我可以添加到标头中的任何内容还是其他什么内容,以确保此email@clientserver.com地址接收到联系表电子邮件吗?

I've tried PHPMailer with no luck either. 我也没有运气尝试过PHPMailer。

<?php

if(empty($_POST['name']) || empty($_POST['email']) || empty($_POST['message'])) {
    die('Error: Missing variables');
}

$name=$_POST['name'];
$email=$_POST['email'];
$phone=$_POST['phone'];
$message=$_POST['message'];

$to='email@clientserver.com';

$headers = 'From: '.$email."\r\n" .
    'Reply-To: '.$email."\r\n" .
    'MIME-Version: 1.0' . "\r\n" .
    'Content-type: text/plain; charset=iso-8859-1' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();
$subject = 'Contact form enquiry';
$body='Dear Client,'."\n\n";
$body.='The following enquiry has been sent through.'."\n\n";
$body.='Name: '.$name."\n";
$body.='Email: '.$email."\n";
$body.='Phone: '.$phone."\n";
$body.='Message: '.$message."\n";

if(mail($to, $subject, $body, $headers, "-femail@clientserver.com")) {
    die('Mail sent');
} else {
    die('Error: Mail failed');
}

?>

Sometimes you have to define security settings among other things, some smtp servers accept different details. 有时您必须定义安全性设置,某些smtp服务器接受不同的详细信息。 I had a problem similar to this and i also had to allow the php extension "php_opnessl". 我有一个与此类似的问题,我也不得不允许php扩展名“ php_opnessl”。

for example: live uses a setup like this 例如:live使用这样的设置

$mail -> Port = 587;
$mail -> SMTPSecure = "tls"; 
$mail -> Host = "smtp.live.com";

while gmail is: 而gmail是:

$mail -> Port = 465;
$mail -> SMTPSecure = "ssl"; 
$mail -> Host = "smtp.gmail.com";

Let me know if any of this helps 让我知道这是否有帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM