Skip to content

Instantly share code, notes, and snippets.

@jmarnold
Created November 11, 2012 00:02
Show Gist options
  • Save jmarnold/4053043 to your computer and use it in GitHub Desktop.
Save jmarnold/4053043 to your computer and use it in GitHub Desktop.
Automated Testing
public class EmailGateway : IEmailGateway
{
private readonly EmailSettings _settings;
private readonly ILogger _logger;
public EmailGateway(EmailSettings settings, ILogger logger)
{
_settings = settings;
_logger = logger;
}
public void Send(MailMessage message)
{
_logger.Debug(() => "Sending Email message to {2} from Host={0} Port={1}".ToFormat(_settings.Host, _settings.Port, message.To.Select(x => x.Address).Join(", ")));
using(var client = new SmtpClient(_settings.Host, _settings.Port))
{
if(_settings.RequiresAuthentication())
{
client.Credentials = new NetworkCredential(_settings.Username, _settings.Password);
}
client.Send(message);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment