Issues

ZF-9876: Override maximum_log in Zend_Mail_Protocol_Abstract

Description

In my app, I want to log the whole SMTP transaction. To do so, I'm using: {quote} $tr->getConnection()->getLog() {/quote}

This works and provides me with the SMTP transaction, however.. its length is limited. Upon further investigation there is an hard coded value MAXIMUM_LOG in Zend_Mail_Protocol_Abstract.

I've (temporarily) modified this from 64 to 4096 so it covers the whole transaction.In my app I remove everything between DATA and the trailing .

Can there be a setter (and getter) to modify this limit?

Comments

Maybe its also possible to add an option to disable the limit/checking of the limit. Setting it to 999999 isn't very pretty.

Patch attached.

Sorry, I have been inactive since last April.

I will review the patch this week and commit it if okay.

Dolf, I hope you haven't forgot about this? :)

I would also love to see a change here because I have the problem that I want to send a mail with attachments >100MB, and my php memory limit of 512 MB is exhausted, I think this log is one of the problems. I would like to disable logging completly, setting MAXIMUM_LOG to 0 is not enough because the big DATA request would be logged anyway into $this->_log and fill up my memory.

Forget the sentence with the big DATA request, I have seen that there are thousands of little log entries instead of one big log entry when sending a big mail.

But I would like to disable this log per default because 99% of the users don't need it, it only wastes CPU. If a developer needs the log he can enable it then, but default should be off. Or default of $_maximumLog should be -1 which disable the log. In _addLog there has to be one line


if ($this->_maximumLog < 0) return;

Resolved on trunk and will be released in the next major release.

Please beware that I'm unsure why originally it was chosen to use a constant for this. If it turns out there was a proper reason for that that's still legit this patch will be reverted.

In any case; thank you for reporting this issues and my apologies for the delays in fixing it.

Your commit is wrong, getMaximumLog is incorrectly named setMaximumLog.

Should be fixed once again. Thanks.

I checked your commit, Dolf, and I cannot see a possibility to disable the log. Should I create a new issue for that?

Because I don't want to log the transaction in production environment, and logging every line is a performance problem, because in my tests when sending a 60MB mail I have 300.000 calls of _addLog and also 300.000 calls of



Best solution would be to have something like

// Save request to internal log if (true == $this->_loggingEnabled) { $this->_addLog($request . self::EOL); }``` in both _send() and _receive() so we don't have thousands of function calls.

Perhaps in ZF 2.0 we could even disable this logging feature by default because only developers need it for debugging, 99% of the users don't need that logging feature in a default installation. This would increase the performance of the component. But this would be a BC.

Just call setMaximumLog(0) and logging is disabled.

@Josh: I don't see it, could you please tell me the line? There is no "return" or something in _addLog(), so the function _addLog() is called every time and an entry is filled into the array $this->_log . You are right that this entry is shifted out on the next call of _addLog(), but it keeps filling the array 300.000 times.