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

问题描述 投票:0回答:1

我已经获得了此脚本,用于在旧服务器上运行良好的联系表单。我们需要移动一台新服务器,现在它仅在我将电子邮件发送到Gmail或实时地址时才有效。如果我尝试将电子邮件发送到我自己的电子邮件[email protected],则无法使用。

    $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("[email protected]", "ActaPrivacy - Richiesta Assistenza", $body, $headers);

php.ini文件与旧服务器中的文件完全相同。服务器是linux,我保留了默认值

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

; For Win32 only.
;sendmail_from = [email protected]

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

我不知道我还能做些什么,奇怪的是,如果我发送到Gmail,它可以正常工作,为什么当我发送到自己的邮件中时,它不起作用?

我已经可以使用PHPMailer,但是我也想了解为什么如果以前使用它并且设置相同,为什么它不能正常工作。

php email
1个回答
0
投票

移至PHPMailer。默认的php邮件功能不支持现代安全功能。您可以看到以gmail收到的电子邮件带有红色的挂锁图标。一些邮箱将永远不会收到不安全的电子邮件。


0
投票

me pasa lo mismo,pero si comento la linea'内容类型:text / html; charset = utf-8'。 “ \ r \ n”funciona bien,

© www.soinside.com 2019 - 2024. All rights reserved.