public Guid Init(ISmtpSocketClient client, ISmtpConfiguration configuration) { if (client == null) { throw new ArgumentNullException("client"); } if (configuration == null) { throw new ArgumentNullException("configuration"); } _client = client; _configuration = configuration; _sessionId = Guid.NewGuid(); return(_sessionId); }
internal MailMessage ProcessMailCommands(ISmtpSocketClient client, MailMessage mailMessage) { client.Write("250 OK"); string lastData = ""; bool hasRecipient = false; while (lastData != ".") { client.ClearLastCommand(); lastData = client.Read("\r\n"); if (client.LastCommand == null) { continue; } switch (client.LastCommand.Verb) { case SmtpVerb.Recipient: if (AddRecipient(client.LastCommand.Arguments.ToArray(), mailMessage)) { hasRecipient = true; } break; case SmtpVerb.Data: if (!hasRecipient) { client.Write("554 no valid recipients"); break; } client.Write("354 Ready to recieve data"); ProcessData(client, mailMessage); return(mailMessage); break; } } return(mailMessage); }
public MailMessage GetMailMessage(SmtpArgument[] mailCommandArguments, ISmtpSocketClient client) { var fromAddress = mailCommandArguments.GetValue(SmtpArgumentName.From); if (fromAddress == null) { throw new SmtpErrorException(ResponseCodes.SmtpResponseCode.SyntaxErrorInCommandArguments, "FROM: not included"); } EmailAddress emailAddress = null; try { emailAddress = new EmailAddress(fromAddress); } catch (ArgumentException argumentException) { throw new SmtpErrorException(ResponseCodes.SmtpResponseCode.RecipientRejected, "Address is invalid", argumentException); } return(ProcessMailCommands(client, new MailMessage(emailAddress))); }
private void ProcessData(ISmtpSocketClient client, MailMessage mailMessage) { throw new NotImplementedException(); }