wxmailto_status Smtp::HandleVRFY(Contact& address) { wxString idna_email = address.GetIdnaEmail(); if (idna_email.IsEmpty()) return LOGERROR(ID_INVALID_FORMAT); wxmailto_status status; wxString read_string, write_string; //Send VRFY, RFC821 §4.1.2 write_string = "VRFY "+idna_email+s_CRLF; if (ID_OK!=(status=Write(write_string, s_raw_encoding))) return status; //Read server-response wxInt smtp_status; wxBool more = true; while (more) { if (ID_OK!=(status=ReadLine(read_string, s_raw_encoding))) return status; smtp_status = SmtpStatus(read_string, more); } Contact* found_email = NULL; switch(smtp_status) //RFC821 §4.3 { case 251: if (ID_OK!=(status=ParseVRFY_EXPAND(read_string, found_email))) return status; //else Success, fallthrough case 250: break; case 550: //Failure, fallthrough case 551: case 553: if (ID_OK!=(status=ParseVRFY_EXPAND(read_string, found_email))) return status; break; //If we find an address, consider this a success case 500: //Error, fallthrough case 501: case 502: case 504: case 421: default: return LOGERROR(ID_ERROR_FROM_SERVER); } if (found_email) { address.SetEmail(found_email->GetEmail()); delete found_email; } return ID_OK; }
wxmailto_status Smtp::HandleEXPAND(const Contact& address, ContactList& addresses) { wxString idna_email = address.GetIdnaEmail(); if (idna_email.IsEmpty()) return LOGERROR(ID_INVALID_FORMAT); wxmailto_status status; wxString read_string, write_string; //Send EXPN, RFC821 §4.1.2 write_string = "EXPN "+idna_email+s_CRLF; if (ID_OK!=(status=Write(write_string, s_raw_encoding))) return status; //Read server-response Contact* found_email = NULL; wxBool more = true; while (more) { if (ID_OK!=(status=ReadLine(read_string, s_raw_encoding))) return status; switch(SmtpStatus(read_string, more)) //RFC821 §4.3 { case 250: if (ID_OK!=(status=ParseVRFY_EXPAND(read_string, found_email))) return status; if (found_email) addresses.Append(found_email); break; case 550: //Failure, fallthrough case 500: //Error, fallthrough case 501: case 502: case 504: case 421: default: return LOGERROR(ID_ERROR_FROM_SERVER); } } return ID_OK; }