メールを送信できなかった場合、レコードを挿入する簡単なテーブルlog
を作成しました。完全なSMTPエラーログを取得できませんPHPメーラー
mysql> describe log;
+--------+-----------+------+-----+---------------------+-----------------------------+
| Field | Type | Null | Key | Default | Extra |
+--------+-----------+------+-----+---------------------+-----------------------------+
| id_log | int(11) | NO | PRI | NULL | auto_increment |
| error | text | YES | | NULL | |
| time | timestamp | NO | | 0000-00-00 00:00:00 | on update CURRENT_TIMESTAMP |
+--------+-----------+------+-----+---------------------+-----------------------------+
そして、私のPHP側では、エラーログがこのようなものです:
foreach ($arrayWithMails as $key => $value) {
$mail->addAddress($value);
if (!$mail->send())
{
put('message', $mail->ErrorInfo); //store in session
// echo $mail->ErrorInfo;
}
else {
/* Add email from array in session to be displayed at main page */
put('emailAddresses', $arrayWithMails); //Store in session
}
$mail->ClearAllRecipients();
}
$log->logError($_SESSION['message']);
それは、パラメータとして文字列を渡して、DBに挿入する私のクラスのメソッドを呼び出します。
しかし、すべての私のログは次のように探しています:
mysql> select * from log;
+--------+------------------------------------------------------------------------------------+---------------------+
| id_log | error | time |
+--------+------------------------------------------------------------------------------------+---------------------+
| 1 | SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting | 2016-10-21 15:08:30 |
| 2 | 1 | 2016-10-21 15:12:04 |
| 3 | 1 | 2016-10-21 15:13:42 |
| 4 | SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting | 2016-10-21 15:14:14 |
| 5 | SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting | 2016-10-21 15:17:02 |
| 6 | SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting | 2016-10-21 15:18:22 |
| 7 | SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting | 2016-10-21 15:28:02 |
| 8 | SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting | 2016-10-21 15:28:53 |
+--------+------------------------------------------------------------------------------------+---------------------+
そして、私のSMTPのデバッグは4
に設定されています。 2
でも同様の結果が試されました。
f.e.私は$mail->ErrorInfo
の基本的なエコーを行います。完全なログにはエラーがありますが、DBにその完全なログ情報を保存したいときは、私だけが得ます: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
$ _SESSION varにそのエラーを保存しようとすると同じことが起こります。
どのように完全なログを保存するか考えていますか? ありがとう!
こんにちは、ありがとうございました。私は実際に私のコードであなたのソリューションを実装する方法は実際にはわかりません。私は私の質問を編集しました。 – fugitive