PHP Mail()成功发送电子邮件,但不出现在Gmail中

发布于 2025-02-01 00:17:07 字数 2854 浏览 2 评论 0原文

我知道这个问题已经很多次,但是我遵循的所有解决方案都没有用于我的案件。

我正在尝试发送基本php mail()函数,我收到mail()返回true,但是未发送的电子邮件未发送到我的<我的<强> gmail 。我确实检查了垃圾邮件文件夹,所有内容!

其他注释 我不必使用 gmail 来从我的 php 脚本发送电子邮件,可以是任何电子邮件!

我正在使用 linux薄荷,我的服务器是 xampp

我的 php.ini

[mail function]

; For Win32 only.
; http://php.net/smtp
SMTP=
; http://php.net/smtp-port
smtp_port=25

; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = 

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path = 

; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =

; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename
mail.add_x_header=On

php code

<?php
error_reporting(-1);
ini_set('display_errors', 'On');
set_error_handler("var_dump");

$to = "[email protected]";
$subject = "My subject";
$txt = "Hello world!";
$headers = 'From: [email protected]' . "\r\n" .
    'Reply-To: [email protected]' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

$res = mail($to, $subject, $txt, $headers);
if ($res){
    echo "Email Sent Succesfully<br>";
} else {
    echo "Error!<br>";
}
?>

编辑注意 我发现我需要安装静止sendmail并将其配置一点,但是在收到终端成功后,电子邮件未出现在Gmail收件箱中:

echo "Subject: sendmail test" | sendmail -v [email protected]

结果:

<[email protected]>... Connecting to local...
050 <[email protected]>... Sent
250 2.0.0 24OG5dE9090992 Message accepted for delivery
[email protected]... Sent (24OG5dE9090992 Message accepted for delivery)
Closing connection to [127.0.0.1]
>>> QUIT

I am aware that this question been asked many times, but all the solutions I followed didn't work for my case.

I am trying to send basic php mail() function, I am receiving that mail() returning TRUE but the email not sent into my gmail. I did check spam folder and all!

ADDITIONAL NOTE
I don't have to use gmail to send emails from my php script, it can be any email!

I am using Linux Mint, my server is XAMPP

my php.ini :

[mail function]

; For Win32 only.
; http://php.net/smtp
SMTP=
; http://php.net/smtp-port
smtp_port=25

; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = 

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path = 

; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =

; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename
mail.add_x_header=On

PHP Code :

<?php
error_reporting(-1);
ini_set('display_errors', 'On');
set_error_handler("var_dump");

$to = "[email protected]";
$subject = "My subject";
$txt = "Hello world!";
$headers = 'From: [email protected]' . "\r\n" .
    'Reply-To: [email protected]' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

$res = mail($to, $subject, $txt, $headers);
if ($res){
    echo "Email Sent Succesfully<br>";
} else {
    echo "Error!<br>";
}
?>

EDIT NOTE
I found that I needed to install still sendmail and configure it a little but still after receiving success in terminal the email not appearing in gmail inbox:

echo "Subject: sendmail test" | sendmail -v [email protected]

RESULTS:

<[email protected]>... Connecting to local...
050 <[email protected]>... Sent
250 2.0.0 24OG5dE9090992 Message accepted for delivery
[email protected]... Sent (24OG5dE9090992 Message accepted for delivery)
Closing connection to [127.0.0.1]
>>> QUIT

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

∞琼窗梦回ˉ 2025-02-08 00:17:07

您可能应该配置您的Gmail以接受三分之二零件的电子邮件。
看看这个通过其他电子邮件平台检查gmail
默认情况下,IMAP和SMTP已关闭。

You should probably configure your Gmail to accept emails from thirds parts.
Have a look of this Check Gmail through other email platforms.
By default Imap and SMTP are off.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文