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

Getting error message by error code #1579

Open
AkinOlawale opened this issue Oct 20, 2018 · 3 comments
Open

Getting error message by error code #1579

AkinOlawale opened this issue Oct 20, 2018 · 3 comments

Comments

@AkinOlawale
Copy link

Hi.

I am trying to implement a resend mail feature in my application. Basically should there be a connection issue or other related problems, the application saves the failed message to a database and then retries again after some minutes.

Is there anyway to get an error code via errorInfo variable? For example, if it is an authentication problem, error code can be 3. etc?

@XL-2000
Copy link

XL-2000 commented Nov 17, 2018

Although this seems a valid question at first glance, you want to resend regardless of the error right?
Where do you need the errorcode for? Next to this, keep in mind that auto-resending might be a bad idea i.e. if you run into quotum or abuse limitations.
Also, any error once the email is delivered to the mail server can not be caught on application-level, so keep in mind this will not be full proof.

@Synchro
Copy link
Member

Synchro commented Nov 18, 2018

I think this is a reasonable request. PHPMailer is usually set up in a fixed configuration, where it is always sending through the same mail server, and so any problems tend to be dealt with interactively during development, at which time descriptive error messages are appropriate.

Send-time SMTP errors already provide SMTP error codes, and bounces (which PHPMailer doesn’t attempt to handle) have embedded error information. Other runtime errors are harder to deal with because they do indeed lack clear error codes that would help you handle them programmaticly.

Something like an ErrorCode property that contains a numeric error code that could be used alongside the ErrorInfo property. Note that the Exception class already provides a value for that, but PHPMailer does not require the use of exceptions - the way exceptions are implemented is a little strange, but you can get more info from them than you can with ErrorInfo alone.

@AkinOlawale
Copy link
Author

@Synchro Yes that's exactly what i have in mind. The ErrorInfo property could be improved to contain numeric code. This should be a feature request

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

3 participants