Sample code for 30+ languages & platforms
SQL Server

Check if the SMTP Server Supports DSN

See more SMTP Examples

Demonstrates the Chilkat MailMan.IsSmtpDsnCapable method, which contacts the SMTP server and determines whether it supports the DSN (Delivery Status Notification) extension defined by RFC 3461. This example configures the SMTP connection and reports whether DSN is available.

Background: DSN lets a sender request a delivery receipt — asking the mail system to report back on success, failure, or delay for each recipient. Not every server offers it, so IsSmtpDsnCapable probes the server's advertised EHLO capabilities first. Checking before relying on DSN-related settings avoids surprises when a server silently ignores a receipt request it does not support.

Chilkat SQL Server Downloads

SQL Server
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    --  Demonstrates the MailMan.IsSmtpDsnCapable method, which contacts the SMTP server and
    --  determines whether it supports the DSN (Delivery Status Notification) extension defined
    --  by RFC 3461.

    DECLARE @mailman int
    EXEC @hr = sp_OACreate 'Chilkat.MailMan', @mailman OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    --  Configure the SMTP server connection.
    EXEC sp_OASetProperty @mailman, 'SmtpHost', 'smtp.example.com'
    EXEC sp_OASetProperty @mailman, 'SmtpPort', 465
    EXEC sp_OASetProperty @mailman, 'SmtpSsl', 1
    EXEC sp_OASetProperty @mailman, 'SmtpUsername', 'user@example.com'
    EXEC sp_OASetProperty @mailman, 'SmtpPassword', 'myPassword'

    --  Check whether the server supports DSN.
    DECLARE @dsnCapable int
    EXEC sp_OAMethod @mailman, 'IsSmtpDsnCapable', @dsnCapable OUT

    IF @dsnCapable = 1
      BEGIN

        PRINT 'The SMTP server supports DSN.'
      END
    ELSE
      BEGIN

        PRINT 'The SMTP server does not support DSN.'
      END

    --  Note: Explicitly connecting/authenticating is optional.  Chilkat MailMan automatically
    --  connects and authenticates -- using the property settings above -- whenever a server
    --  operation requires it.  Calling the explicit connect/authenticate methods can still be
    --  helpful to determine whether a failure occurs while connecting or while authenticating.

    EXEC @hr = sp_OADestroy @mailman


END
GO