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

Remove Undeliverable Mail from the queue #8

Open
Taprik opened this issue Oct 16, 2014 · 3 comments
Open

Remove Undeliverable Mail from the queue #8

Taprik opened this issue Oct 16, 2014 · 3 comments
Assignees
Milestone

Comments

@Taprik
Copy link

Taprik commented Oct 16, 2014

When using a gmail smtp server, the recipient address needs to be a valid email format (with a @ followed by a .)

Here is a function that can check that

bool is_email(std::string const& address) {
size_t at_index = address.find_first_of('@', 0);
return at_index != std::string::npos
&& address.find_first_of('.', at_index) != std::string::npos;
}

This function could be called in the send function of the smtp client.

Sorry, I'm a very beginner with Github ...

@bakercp
Copy link
Owner

bakercp commented Oct 18, 2014

Currently the behavior I'm getting from ofxSMTP and GMail is that if sent to an invalid email, GMail returns an error that looks like this when sent to an email like "junkaddress":

[ error ] Client::threadedFunction: SMTP Exception : SMTP Exception: Recipient rejected: <junkaddress>: 553-5.1.2 We weren't able to find the recipient domain. Please check for any
553-5.1.2 spelling errors, and make sure you didn't enter any spaces, periods,
553 5.1.2 or other punctuation after the recipient's email address. mj3sm1311496igb.11 - gsmtp

Even after this failure, the message stays in the queue.

Then, so in your opinion, if a message fails to send, it should be removed from the queue?

@Taprik
Copy link
Author

Taprik commented Oct 18, 2014

Hi bakercp,

Actually I'm speaking of mail addres that are not string in an email format (with a @ followed by a .)

I'm using ofxSMTP on a permanent installation. People can enter their email.
If the user enters nothing and hit "send" or if he enters kjhsdgf and hits "send", I've got the error
[ error ] Client::threadedFunction: SMTP Exception : SMTP Exception: Recipient rejected: <>: 555 5.5.2 Syntax error. fq1sm9143606wib.12 - gsmtp
Recipient rejected is blank, and any further valid (or in the right string email format) email address returns the same error.
With the is_email function of my first post I check if the string entered have a @ followed by a .
And everything is fine.

I choose to not send to the queue addresses that are not in the email format.

Cheers

@bakercp bakercp changed the title ofxsmtp stop sending email Remove Undeliverable Mail from the queue Oct 21, 2014
@bakercp
Copy link
Owner

bakercp commented Oct 21, 2014

OK. So the main issue I see here is that if the server responds with a 500 series error (unrecoverable), then the message that caused that error needs to be marked as a delivery failure and removed from the queue.

While I'm OK with adding a utility method to check for valid email addresses, I'd prefer to leave that up to the server when sending a message failure.

I started work on fixing this and will add it to the next version. For the time being, the work around is to do exactly what you did -- pre-validate email addresses before submitting them the the send queue.

@bakercp bakercp self-assigned this Oct 21, 2014
@bakercp bakercp added this to the 0.9.0 milestone Oct 21, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants