简体   繁体   中英

How to Configure database mail in SQL Server 2012

I'm tried to configure the database mail with Gmail SMTP Server, getting a message like:

The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 4 (2019-01-11T14:46:42). Exception Message: Cannot send mails to mail server. (Failure sending mail.).

Can anyone give solutions for this

Your question is very general, but the first step is to create a profile and account using Configure Database Mail Wizard : In Object Explorer , go to Management > Database Mail and Create a new e-mail profile and specify its SMTP accounts .

Once that's done you can test by sending an email, like this:

USE msdb
GO
EXEC sp_send_dbmail @profile_name='ProfileName',
@recipients='test@Example.com',
@subject='Title email',
@body='This is the body of my email'

You should check your port and server adress to your mail. For example: Port: 587 server: smtp.gmail.com Remember, your SQL Agent should be enable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM