简体   繁体   English

PHP 邮件功能发送到 Gmail 和 Live,但不发送到我自己的电子邮件

[英]PHP mail function sends to Gmail and Live but doesn't send to my own email

I've got this script for a contact form that was working well on the old server.我有这个脚本,用于在旧服务器上运行良好的联系表单。 We needed to move on a new server and now it only works if I send emails to Gmail or Live address.我们需要搬到一个新服务器上,现在它只有在我将电子邮件发送到 Gmail 或 Live 地址时才有效。 If I try to send emails to my own email assistenzatecnica@actainfo.it, it doesn't work.如果我尝试将电子邮件发送到我自己的电子邮件assistenzatecnica@actainfo.it,则不起作用。

    $from = trim($_POST['email']);
    $message = trim($_POST['message']);
    $username = trim($_POST['username']);

    /*Invia mail*/
    $body = '<html><body>';
    $body .= '<p><strong>Da:</strong> '.$username.' - '.$from.'</p>';
    $body .= '<p>'.$message.'</p>';
    $body .= '</body></html>';
    $headers = 'From: '.$from.'' . "\r\n";
    $headers .= 'MIME-Version: 1.0' . "\r\n" .
    'Content-type: text/html; charset=utf-8' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();
    mail("assistenzatecnica@actainfo.it", "ActaPrivacy - Richiesta Assistenza", $body, $headers);

The php.ini file is exactly the same as the one from the old server. php.ini 文件与旧服务器中的完全相同。 Server is linux and I left the default values服务器是 linux,我保留了默认值

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

; For Win32 only.
;sendmail_from = me@example.com

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
sendmail_path = /usr/sbin/sendmail -t -i

I don't know what else I can do, what's weird is that it works if I send to Gmail, so why it doesn't work when I send to my own mail?我不知道我还能做什么,奇怪的是如果我发送到 Gmail 就可以了,那么为什么当我发送到我自己的邮件时它不起作用?

I can already move to PHPMailer, but I would also like to understand why this is not working properly if it was working before and the settings are the same.我已经可以转移到 PHPMailer,但我也想了解为什么如果它以前工作并且设置相同,为什么它不能正常工作。

Do move to PHPMailer.移动到 PHPMailer。 Default php mail functions do not support modern security features.默认的 php 邮件功能不支持现代安全功能。 You can see that emails you received in gmail have a red padlock icon.您可以看到您在 gmail 中收到的电子邮件有一个红色的挂锁图标。 Some of the mailboxes will never receive an unsecure email.某些邮箱永远不会收到不安全的电子邮件。

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

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