Try to sending email not working with suscription in Reporting Services

Amin 1 Reputation point
2021-12-20T18:02:10.847+00:00

Try to sending email not working with suscription in Reporting Services, the error is :

emailextension!WindowsService_29!475c!12/20/2021-07:00:08:: e ERROR: Error sending email. Exception: System.AggregateException: One or more errors occurred. ---> System.Net.Mail.SmtpException: The server committed a protocol violation The server response was:
at System.Net.Mail.SendMailAsyncResult.End(IAsyncResult result)
at System.Net.Mail.SmtpClient.SendMailCallback(IAsyncResult result)
--- 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: The server committed a protocol violation The server response was:
at System.Net.Mail.SendMailAsyncResult.End(IAsyncResult result)
at System.Net.Mail.SmtpClient.SendMailCallback(IAsyncResult result)<---
. Additional Information: SmtpException StatusCode:GeneralFailure
notification!WindowsService_29!475c!12/20/2021-07:00:08:: e ERROR: Error occurred processing subscription d218375a-a99f-4b7a-98e5-4bbcb6f4b6d2: Failure sending mail: One or more errors occurred.Mail will not be resent.

is any idea to solven the error?

Best regards

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,064 questions
{count} votes

13 answers

Sort by: Most helpful
  1. Ross Camardo 21 Reputation points
    2022-01-10T13:23:52.623+00:00

    Hello,

    So just as a heads up for me the answer was .net more specifically how .net handles TLS separately than SSRS.

    Check out this article
    https://argonsys.com/microsoft-cloud/library/tls-and-sql-server-reporting-services-an-interesting-interaction/

    Msoft has been deprecating TLS 1.0 for a while now and its becoming more prevalent as they are slowly allowing them to fail currently.
    Forcing TLS 1.2 and Forcing it for .NET seems to have fixed things up for us.

    Thank you.

    4 people found this answer helpful.

  2. GlockByte 161 Reputation points
    2022-01-07T19:03:41.323+00:00

    @Amin @04147834 @Ilan Prudhomme @Mike (Elcee) @Joshua Pries

    I made a few changes that have now made all of mine succeed since. My issue was intermittent. It would randomly fail then succeed without any real pattern to go off of. I view this as a temporary fix until I find what the root cause is.

    The (temp) fix was editing the web.config. When IIS checks if headers are complete, an exception is being thrown and the request is rejected. I personally needed to restart the server after changes were made

    When a protocol violation occurs, a WebException exception is thrown with the status set to ServerProtocolViolation. If the UseUnsafeHeaderParsing property is set to true, validation errors are ignored.
    -Microsoft

    web.config:

    <configuration>  
        <system.webServer>  
            <httpProtocol allowKeepAlive="false" />  
        </system.webServer>  
    </configuration>  
    <system.net>  
        <settings>  
            <servicePointManager expect100Continue="true"/>   
            <httpWebRequest useUnsafeHeaderParsing="true" />  
        </settings>  
    </system.net>  
    

    Once I find a permanent solution I will post it back here. When I have more time, I'll have to check my headers and report back here what exactly was causing the validation error. I am currently monitoring and I'll come back here to post if anymore failures occur and what my remedy is.
    T-SQL query check for fails, returning your execution script so you can manually execute the failures (for those not familiar with SQL):

    SELECT   
     CASE   
     WHEN s.[LastStatus] LIKE 'Failure sending mail%' THEN 0   
     WHEN s.[LastStatus] LIKE 'Mail Sent%' OR s.[LastStatus] LIKE 'Done%' THEN 1  
     END AS [Success],  
     'exec sp_start_job @job_name = ''' + cast(j.name as varchar(40)) + '''' AS [script],   
     s.[Description],   
     s.[LastStatus],   
     js.[last_run_duration],   
     js.[last_run_outcome],   
     js.[last_run_retries],   
     s.[LastRunTime]       
    FROM msdb.dbo.sysjobs j   
    LEFT JOIN msdb.dbo.sysjobsteps js ON js.job_id = j.job_id          
    LEFT JOIN [ReportServer].[dbo].[Subscriptions] s on js.command like '%' + cast(s.subscriptionid as varchar(40)) + '%'  
    WHERE [lastruntime] >= DATEADD(dd, -7, DATEDIFF(dd, 0, GETDATE()))  
    

    Here are the validations performed during HTTP parsing:

    • In end-of-line code, use CRLF; using CR or LF alone is not allowed.
    • Headers names should not have spaces in them.
    • If multiple status lines exist, all additional status lines are treated as malformed header name/value pairs.
    • The status line must have a status description, in addition to a status code.
    • Header names cannot have non-ASCII chars in them. This validation is performed whether the HttpWebRequestElement.UseUnsafeHeaderParsing property is set to true or false.

    ----------

    Just in case it's related to anyone with a connection issue. I had previously also made a change for a connection issue by adding key values to the registry as per Microsoft's How to enable TLS 1.2 on clients documentation. This allows .NET to use the OS's TLS settings rather than attempting to use a disabled TLS 1.0 and failing

    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v2.0.50727]  
          "SystemDefaultTlsVersions" = dword:00000001  
          "SchUseStrongCrypto" = dword:00000001  
    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319]  
          "SystemDefaultTlsVersions" = dword:00000001  
          "SchUseStrongCrypto" = dword:00000001  
    
    1 person found this answer helpful.

  3. Isabellaz-1451 3,616 Reputation points
    2021-12-21T01:38:07.637+00:00

    Hi @Amin

    There are many reasons for subscription failure
    Common problems with subscription delivery:

    • The SQL Server Agent job is not firing
    • RS is not processing the subscription events
    • SMTP is not delivering the emails
    • The report or subscription is invalid

    You can refer to this thread to troubleshoot your subscription :
    https://learn.microsoft.com/zh-cn/archive/blogs/deanka/monitoring-and-troubleshooting-subscriptions

    And here is a post similar to your issue,hope will help you: https://social.msdn.microsoft.com/Forums/sqlserver/en-US/edff6181-4b1c-43cb-a958-c93b60c67e5d/why-is-my-ssrs-email-subscription-not-sending-email?forum=sqlreportingservices

    Best Regards,
    Isabella


    If the answer is the right solution, please click "Accept Answer" and upvote it. If you have extra questions about this answer, please click "Comment".
    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.


  4. 04147834 6 Reputation points
    2021-12-21T12:33:40.02+00:00

    I too am having this problem. I applied all Windows Server 2019 updates, updated SSRS to the current version, updated .Net to the current version. Rebooting the server sometimes temporarily helps. The program began around December 10, 2021. I was using Office 365's SMTP server. Changing the server doesn't seem to help. Manually triggering the report works maybe 30% of the time. The error log does not have any useful information to troubleshoot.


  5. Amin 1 Reputation point
    2021-12-21T16:53:26.797+00:00

    Thanks for the answers.

    I have configure the subscription with office 365 in cloud, we have around 970 subscriptions enabled.
    I investigated that Microsft have restrictios with STMP sending emails it's 30 emails each minute.

    Some subscriptions are sent but others are not random. Every day I have about 300 errors for mailing.

    Could is the root issue?

    Best regards


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.