Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I save the sendlog to file without output? #911

Closed
wilon opened this issue Dec 22, 2016 · 4 comments
Closed

How can I save the sendlog to file without output? #911

wilon opened this issue Dec 22, 2016 · 4 comments

Comments

@wilon
Copy link

wilon commented Dec 22, 2016

No description provided.

@Synchro
Copy link
Member

Synchro commented Dec 22, 2016

It's not quite clear, but I assume you mean you want to capture debug output when SMTPDebug = 2. You can do this by injecting a function into the Debugoutput property, like this:

$mail->SMTPDebug  = 2;
$mail->Debugoutput = function($str, $level) {
    file_put_contents('smtp.log', gmdate('Y-m-d H:i:s'). "\t$level\t$str\n", FILE_APPEND | LOCK_EX);
};

This is described in the source code.

@Synchro Synchro closed this as completed Dec 22, 2016
@d3v3lop3rtuta
Copy link

Hi Synchro,
I have been playing around with the codes and creating different problems too :v
FILE_APPEND works fine and i like the fact that all error gets stored in smtp.log and i can read the smtp.log file to check if the error causing my code to stop is a wrong password or too many login attempt , the problem is Append keeps adding to the same smtp.log which can be misleading , if the first password attempt was a wrong password and the second attempt generates too many login attempts error .. I would like to know the work arround with this as FILE_OVERWRITE overwrites the whole log and leave just the last line "2019-07-28 12:58:07 2 SMTP Error: Could not authenticate." leaving out important information like "2019-07-28 12:58:07 2 SERVER -> CLIENT: 535 5.7.0 (#AUTH005) Too many bad auth attempts." which is what i need to tell my code the next line of action..

@Synchro
Copy link
Member

Synchro commented Jul 29, 2019

(moved comment to #1795)

@Fjeldfross
Copy link

One thing that I've done with this log file problem is to append a date to the log file and then change that date at a reasonable interval. So, for one application which does not log very much, I append the year-month to the name (e.g. smtp_2020-06.log) and then start a new file the next month (e.g. smtp_2020-07.log). You could modify this to start a new log file every week or every day if you wanted depending on your needs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants