簡體   English   中英

mail()函數顯然無法正常工作的電子郵件

[英]mail() function aparently working emails not arriving

嗨,首先,我測試郵件功能,允許顯示錯誤並使用它進行測試。

<?php

error_reporting(E_ALL);
ini_set('display_errors', '1');


$email = "demo@gmail.com";
$subject = "Test Message";
$msg = "This is a test message";

$eLog="/tmp/mailError.log";

//Get the size of the error log
//ensure it exists, create it if it doesn't
$fh= fopen($eLog, "a+");
fclose($fh);
$originalsize = filesize($eLog);

mail($email,$subject,$msg);

/*
* NOTE: PHP caches file status so we need to clear
* that cache so we can get the current file size
*/

clearstatcache();
$finalsize = filesize($eLog);

//Check if the error log was just updated
if ($originalsize != $finalsize) {
print "Problem sending mail. (size was $originalsize, now $finalsize) See $eLog
";
} else {
print "Mail sent to $email";
}
?>

告訴我這正在工作並正在發送電子郵件。

問題是應該使用此代碼發送的郵件沒有到達demo@gmail.com帳戶(如果我更改為真實電子郵件,則該帳戶)

為什么? 在php.ini中也似乎很好,但也許即時通訊沒有在尋找正確的參數。

我不在乎那票選票,好吧,我終於明白了這是怎么回事,這應該可以幫助另一個像我這樣的“不是上帝的程序員”一個凡人。

如果您使用的是Linux服務器,則似乎mail()函數已發送到sendmail函數,要啟用此功能,您必須安裝postfix。

這很容易..並且解決了我所有的問題。

http://whiletruecode.com/post/setting-up-phps-mail-function-on-a-linode-server

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM