Use different env var for SMTP
This commit is contained in:
parent
7d656961a6
commit
34e8e00dfe
@ -13,15 +13,15 @@ public interface ISmtpService {
|
|||||||
public class SmtpService : ISmtpService {
|
public class SmtpService : ISmtpService {
|
||||||
private ILogger<SmtpService> _logger;
|
private ILogger<SmtpService> _logger;
|
||||||
private ISmtpClientWrapper _smtpClient;
|
private ISmtpClientWrapper _smtpClient;
|
||||||
private string _environmentName;
|
private bool _shouldSendEmail;
|
||||||
|
|
||||||
public SmtpService(ILogger<SmtpService> logger, ISmtpClientWrapper smtpClient) {
|
public SmtpService(ILogger<SmtpService> logger, ISmtpClientWrapper smtpClient) {
|
||||||
_logger = logger ??
|
_logger = logger ??
|
||||||
throw new ArgumentNullException("ILogger not injected");
|
throw new ArgumentNullException("ILogger not injected");
|
||||||
_smtpClient = smtpClient ??
|
_smtpClient = smtpClient ??
|
||||||
throw new ArgumentNullException("SmtpClient not injected");
|
throw new ArgumentNullException("SmtpClient not injected");
|
||||||
_environmentName = Environment.GetEnvironmentVariable("FabApprovalEnvironmentName") ??
|
if (!Boolean.TryParse(Environment.GetEnvironmentVariable("FabApprovalShouldSendEmail"), out _shouldSendEmail))
|
||||||
throw new ArgumentNullException("FabApprovalEnvironmentName environment variable not found");
|
throw new ArgumentNullException("FabApprovalShouldSendEmail environment variable not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> SendEmail(IEnumerable<MailAddress> recipients,
|
public async Task<bool> SendEmail(IEnumerable<MailAddress> recipients,
|
||||||
@ -40,7 +40,7 @@ public class SmtpService : ISmtpService {
|
|||||||
bool messageWasSent = false;
|
bool messageWasSent = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!_environmentName.ToLower().Equals("development")) {
|
if (_shouldSendEmail) {
|
||||||
int remainingRetries = maxRetries;
|
int remainingRetries = maxRetries;
|
||||||
while (!messageWasSent && remainingRetries > 0) {
|
while (!messageWasSent && remainingRetries > 0) {
|
||||||
try {
|
try {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user