2017-02-02 31 views
3

SQL Serverからトリガーに電子メールを送信しようとしています。私はthisブログの指針に従って行った。私が電子メールとして試しているときはいつでも、私はエラーが発生しています。SQL Serverから電子メールを送信できません

EXEC msdb.dbo.sysmail_add_account_sp 
    @account_name = 'ChandreshTestAccount' 
    , @description = 'Sending email from test account' 
    , @email_address = '[email protected]' 
    , @display_name = 'No-Reply' 
    , @replyto_address = '[email protected]' 
    , @mailserver_name = 'smtp.gmail.com' 
    , @port = 25 
    , @username = '[email protected]' 
    , @password = 'xxxxxxx' 
Go 

Error: The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 6 (2017-02-02T14:24:46). Exception Message: Could not connect to mail server. (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 74.125.68.109:25). )

それから私は、ポート番号587を変更しようと、以下のエラーを持っています。

The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 5 (2017-02-02T14:28:22). Exception Message: Cannot send mails to mail server. (The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first. n8sm30283000pgc.16 - gsmtp).)

は、その後、再び私は、ポート番号465を変更しようと以下のエラー

The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 4 (2017-02-02T14:28:19). Exception Message: Cannot send mails to mail server. (Failure sending mail.).)

を持っている私が行方不明です何がありますか? 注:ローカルマシンでこれを試しており、C#コード(Port 25

)で電子メールを送信できます。ありがとうございました。

+0

SQLメールは設定されテストされていますか? – BugFinder

+0

私はこのブログに従っています:http://surajpassion.in/sending-email-using-stored-procedures-in-sql-server/ –

答えて

2

としてはMSDN: How to configure SQL Server Database Mail to send email using your Windows Live Mail Account or your GMail Accountに、Q & Sending email in .NET through Gmailで説明すると表示されたエラーが示すように、あなたは、ポートに587 安全な接続を使用する必要があります。

5.7.0 Must issue a STARTTLS command first

をので、渡します@enable_ssl=1パラメータをsysmail_add_account_spに設定します(MSDN: sysmail_add_account_sp (Transact-SQL)で説明)。

+0

ありがとう、それは今働いています:) –

関連する問題