SSRS: ERROR: Error sending email. Exception: System.Net.Mail.SmtpException: Failure sending mail

Kundur Rudresh 1 Reputation point
2021-01-18T12:26:06.44+00:00

I am constantly getting the following error when sending out email subscriptions, below is the Error details in log file.


emailextension!WindowsService_12!2130!01/18/2021-06:46:30:: e ERROR: Error sending email. Exception: System.Net.Mail.SmtpException: Failure sending mail. ---> System.IO.IOException: Unable to read data from the transport connection: net_io_connectionclosed.
at System.Net.Mail.SmtpReplyReaderFactory.ProcessRead(Byte[] buffer, Int32 offset, Int32 read, Boolean readLine)
at System.Net.Mail.SmtpReplyReaderFactory.ReadLines(SmtpReplyReader caller, Boolean oneLine)
at System.Net.Mail.SmtpReplyReaderFactory.ReadLine(SmtpReplyReader caller)
at System.Net.Mail.CheckCommand.Send(SmtpConnection conn, String& response)
at System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[] command, MailAddress from, Boolean allowUnicode)
at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, Boolean allowUnicode, SmtpFailedRecipientException& exception)
at System.Net.Mail.SmtpClient.Send(MailMessage message)
--- End of inner exception stack trace ---
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at Microsoft.ReportingServices.EmailDeliveryProvider.EmailProvider.Deliver(Notification notification)
notification!WindowsService_12!2130!01/18/2021-06:46:30:: e ERROR: Error occurred processing subscription b0ef6472-f255-48ed-bb1d-79a813ee4d64: Failure sending mail: Failure sending mail.


Below is the Config file configuration for sendgrid SMTP:

        <Extension Name="Report Server Email" Type="Microsoft.ReportingServices.EmailDeliveryProvider.EmailProvider,ReportingServicesEmailDeliveryProvider">
            <MaxRetries>3</MaxRetries>
            <SecondsBeforeRetry>900</SecondsBeforeRetry>
            <Configuration>
                <RSEmailDPConfiguration>
                    <SMTPServer>smtp.sendgrid.net</SMTPServer>
                    <SMTPServerPort>
                    </SMTPServerPort>
                    <SMTPAccountName>
                    </SMTPAccountName>
                    <SMTPConnectionTimeout>
                    </SMTPConnectionTimeout>
                    <SMTPServerPickupDirectory>
                    </SMTPServerPickupDirectory>
                    <SMTPUseSSL>True</SMTPUseSSL>
                    <SendUsing>2</SendUsing>
                    <SMTPAuthenticate>1</SMTPAuthenticate>
                    <SendUserName>**********</SendUserName>
                    <SendPassword>***********</SendPassword>

Reports running fine,i dont think its an timeout error.

(Very recently we have changed Sendgrid Username/Password with APIKeys)

any help would be appreciated..

SQL Server Reporting Services
SQL Server Reporting Services
A SQL Server technology that supports the creation, management, and delivery of both traditional, paper-oriented reports and interactive, web-based reports.
3,061 questions
SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,702 questions
SQL Server Other
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. Joyzhao-MSFT 15,631 Reputation points
    2021-01-19T03:08:11.107+00:00

    Hi @Kundur Rudresh ,

    <SMTPAuthenticate>1</SMTPAuthenticate>

    Try to set <SMTPAuthenticate>0</SMTPAuthenticate>

    SMTPAuthenticate
    Specifies an integer value that indicates the kind of authentication to use when sending messages to an SMTP service over a TCP/IP connection. Valid values are:

    • 0=No authentication.
    • 1= (not supported).
    • 2= NTLM (NT LanMan) authentication. The security context of the Report Server Windows service is used to connect to the network SMTP server.

    Best Regards,
    Joy


    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Kundur Rudresh 1 Reputation point
    2021-01-19T12:23:44.037+00:00

    Here is the solution for our problem:

    Very recently SendGrid stopped basic authentication method to send mail (our servers were configured long back).

    To fix this issue, we have updated Email Settings in "Reporting Services Configuration Manager".
    with
    Authentication: UserName and Password (Basic) -> Dropdown.
    UserName: apikey
    Password: very long WEIRED API Key generated Generated at SendGrid.


  3. Shivendoo Kumar 751 Reputation points
    2021-03-28T22:53:16.933+00:00

    Hi All,
    Since last Friday, One of the SSRS report subscriptions is not working. This SSRS subscription has an excel attached to it while sending an email.
    On Friday actually, there was no error message on Report manager but subscribers did not receive the email. When I rescheduled the subscription It worked fine 2nd time.

    I changed it back to the original schedule time that was 9 am and today it failed with the below error message:

    again today I rescheduled it 5 minutes after and it worked fine. There are other subscriptions and those are working fine.

    I checked SMTP configuration and currently, it is set to no authentication.

    emailextension!WindowsService_16!3b00!03/29/2021-09:00:27:: e ERROR: Error sending email. Exception: System.AggregateException: One or more errors occurred. ---> System.Net.Mail.SmtpException: Failure sending mail. ---> System.IO.IOException: Unable to write data to the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
    at System.Net.Sockets.Socket.UnsafeBeginSend(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags, AsyncCallback callback, Object state)
    at System.Net.Sockets.NetworkStream.UnsafeBeginWrite(Byte[] buffer, Int32 offset, Int32 size, AsyncCallback callback, Object state)
    --- End of inner exception stack trace ---
    at System.Net.Mime.MimeBasePart.EndSend(IAsyncResult asyncResult)
    at System.Net.Mail.SmtpClient.SendMessageCallback(IAsyncResult result)
    --- End of inner exception stack trace ---
    --- End of inner exception stack trace ---
    at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
    at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
    at System.Threading.Tasks.Task.Wait(TimeSpan timeout)
    at Microsoft.ReportingServices.EmailDeliveryProvider.EmailProvider.Deliver(Notification notification)
    ---> (Inner Exception #0) System.Net.Mail.SmtpException: Failure sending mail. ---> System.IO.IOException: Unable to write data to the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
    at System.Net.Sockets.Socket.UnsafeBeginSend(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags, AsyncCallback callback, Object state)
    at System.Net.Sockets.NetworkStream.UnsafeBeginWrite(Byte[] buffer, Int32 offset, Int32 size, AsyncCallback callback, Object state)
    --- End of inner exception stack trace ---
    at System.Net.Mime.MimeBasePart.EndSend(IAsyncResult asyncResult)
    at System.Net.Mail.SmtpClient.SendMessageCallback(IAsyncResult result)
    --- End of inner exception stack trace ---<---
    . Additional Information: SmtpException StatusCode:GeneralFailure
    notification!WindowsService_16!3b00!03/29/2021-09:00:27:: e ERROR: Error occurred processing subscription 26e5d27c-a524-467e-aba4-a977ad6b36f7: Failure sending mail: One or more errors occurred.

    Please help

    0 comments No comments

  4. Evan Chatter 16 Reputation points
    2021-07-27T06:59:35.91+00:00

    In my experienced using C# SMTP Client, there is a certain steps to follow in the code (see code snippet below)

    smtpClient.Host = "smtp.gmail.com";
    smtpClient.Port = 587;
    smtpClient.EnableSsl = true;
    smtpClient.UseDefaultCredentials = false;
    smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
    smtpClient.Credentials = new NetworkCredential("account@Stuff .com", "secretPassword");
    smtpClient.Send(mail);

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.