2012-01-21 10 views
0

通知を行うためにかなりの電子メールを送信するスクリプトがありますが、SMTP認証されていないのでメールはそのままジャンクになります。認証されるようにするにはどうすればよいですか?Linux、Cent OSでSMTP認証を使用してメールを送信

私は次のスクリプト使用しています:メールはジャンクボックスに行った理由は、例えば、様々なことがあり

$to = $email . ', '; // note the comma 

// subject 
$subject = 'MineAlert - Server Down'; 

// message 
$message = ' 
<html> 
<head> 
    <title>Your server seems to be down, this could be because it has crashed or you have stopped it</title> 
</head> 
<body> 
    <p>Your server seems to be down, this could be because it has crashed or you have stopped it</p> 

    <p>IP: <b>'.$ip.'</b><br> 
    <p>Port: <b>'.$port.'</b><br> 
    <p>Reason: <b>Unknown</b><br> 
    <br> 
    This email has been generated and sent to you by 

</body> 
</html> 
'; 

$headers = 'MIME-Version: 1.0' . "\r\n"; 
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 

// Additional headers 
$headers .= 'From: [email protected]' . "\r\n"; 

// Mail it 
$mail = mail($to, $subject, $message, $headers); 
if (!$mail){ 
    echo "Mail did not send"; 
} else { 
    echo "Mail Sent"; 
} 
+0

['mail()'関数](http://www.hardened-php.net/suhosin/configuration.html#suhosin.mail.protect)に注意してください。 – sarnold

答えて

0

を実際に所有していないドメイン(gmail.comなど)からのメールであると主張しています。

"公式の" SMTPサーバー(たとえばgmail)に接続し、そのサーバーで電子メールを送信すると問題は解決します。しかし、私の意見では、この問題はPHPスクリプトで解決されるべきではなく、あなたのMTA(Mail Transfer Agent)プログラムで解決されるべきです。 DebianでExim4をMTAとして使用した設定例はhereです。他のOSの設定は似ているはずです。 PHPスクリプトを変更する必要はありません。

[更新]私はより多くの検索を行い、問題がPHPスクリプトで解決できることがわかりました。 This articleが有用かもしれません。

関連する問題