0
votes

I have a SMTP Server configured in web config file. This a default SMTP server to send mail to client.

Sometime if this default SMTP Server failed to send email to any client I have to notify admin by sending email by using different SMTP Server which I want to achieve by using NLOG.

Configuration for NLOG is

    <target name="sendMail" xsi:type="Mail" html="true" 
                      subject="Mail Sending failed" 
                      body="${message}" 
                      to="[email protected]" 
                      from="[email protected]"
                      encoding="UTF-8"
                      enableSsl="False"
                      smtpUsername="[email protected]"
                      smtpPassword="$mySecurePass12#$"
                      smtpServer="smtp.xxxxxxxx.com"
                      smtpPort="xxx"/>
     </targets>



<logger name="SMTPServerChecker.SMTPCheck" minlevel="Info" writeTo="sendMail" />

I am also logged this error in a file which is working perfectly but not getting any mail

In catch block code I have following code

catch (SmtpException ex)
            {

                NLog.LogManager.GetCurrentClassLogger().Error(ex);
            }
1

1 Answers

0
votes

I solve this by adding useSystemNetMailSettings="False" smtpAuthentication="Basic"

in nLog config file