Created
November 11, 2012 00:02
-
-
Save jmarnold/4053043 to your computer and use it in GitHub Desktop.
Automated Testing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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