我知道这是一个被问了很多的问题,但是我已经完成了其他线程中的步骤,但似乎没有帮助。已经为此苦苦挣扎了一周,非常感谢帮助!
以下是关键部分:
- 邮件()返回真
- 电子邮件没有到达
- 我从 site@mysite.com 发送,它在 Bluehost 和 Gsuite 上都设置了匹配的密码
- Bluehost 坚持他们所有的 SMTP 设置/MX 记录都是正确的
- GSuite 电子邮件记录日志显示我网站的队列中没有电子邮件(他们坚持认为这是 Bluehost 的错)
- error_reporting(E_ALL) 什么也不显示
- HTML 将所有变量正确发布到 PHP
- 两个电子邮件帐户(发送和接收)都可以发送和接收电子邮件
我认为 SMTP 设置可能是错误的,但 Bluehost 支持说他们不能直接更改这些。详情如下...
PHP代码
<?php
//ERROR REPORTING
//error_reporting(E_ALL);
//ini_set('display_errors', '1');
//POST VALUES
$name=$_POST['name'];
$business=$_POST['business_name'];
$email=$_POST['email_address'];
$subject='[CONTACT PAGE] '
.strtoupper($_POST['subject'])
.' request from $name'
.' ($business)';
// The above variables confirmed to all POST
$message = '[name] '.$name.'\n'
.'[business] '.$business.'\n'
.'[email] '.$email.'\n\n'
.'[subject] '.$subject.'\n'
.$_POST['message'];
$to = 'support@mysite.com';
$from = 'site@mysite.com'; //Email set up on Gsuite
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= 'From: '.$from;
if (mail($to, $subject, $message, $headers)) {
$location='Location: ./contact-thanks.php';
} else {
$location='Location: ./error';
}
header($location);
die();
?>
MX记录
priority host record points to ttl action
1 @ aspmx.l.google.com 14400 edit delete
5 @ alt1.aspmx.l.google.com 14400 edit delete
5 @ alt2.aspmx.l.google.com 14400 edit delete
10 @ alt3.aspmx.l.google.com 14400 edit delete
10 @ alt4.aspmx.l.google.com 14400 edit delete
蓝色主机电子邮件配置
Email Settings
Mail Server Username: site@mysite.com
Standard (without SSL)
Incoming Mail Server: mail.mysite.com
Supported Ports: 143 (IMAP), 110 (POP3)
Outgoing Mail Server: mail.mysite.com
Supported Port: 26 (server requires authentication)
Private (with SSL)
Incoming Mail Server: mail.mysite.com
Supported Ports: 993 (IMAP), 995 (POP3)
Outgoing Mail Server: mail.mysite.com (SSL)
Supported Port: 465 (server requires authentication)
Supported Incoming Mail Protocols: POP3, IMAP
Supported Outgoing Mail Protocols: SMTP