Send mail using SQL Server

Source: Internet
Author: User
Tags how to use sql server imap how to send mail how to use sql

  In a lot of data analysis and integration scenarios, we need to understand the database of key scripts or job execution. This time email alert is a good way to notice. This article starts with a zero, step-by-step description of how to use SQL Server to send messages.

Environment: 126 mailbox. SQL Server 2012.  1. Configure SMTP permissions for a mailbox (most mailboxes are turned off by default, so manual authentication is required) Login 126 Email---"Set---" Pop3/smtp/imap  

2 tick POP3/SMTP service, IMAP/SMTP service, this time will prompt "Please set the authorization code is turned on the service", click OK.   

3 on the Authorization code page, click "Open", after the phone verification, set the authorization code. Please note: The authorization code here is the login password used by the client in the future! the following settings are followed: 

4 Log on to SQL Server, manage---Database Mail---Right-click, configure Database Mail 

5 Select the first item: Install Database Mail by performing the following tasks.   

6. Set the profile name. (This configuration will be used later to send mail) Click "Add" to go to the detailed configuration page.   

7. Configure as shown. There are two points to note:1. Use a different mailbox with a different port number. 126 The port number of the mailbox is 25, if you use another mailbox, you can go onlinecheck out how many SMTP port numbers they use by default. 2. The following identity authentication password must be the previously mentioned authorization code! Not the login password of the mailbox. (the concept of authorization code is also to ensure that the mailbox password is not compromised, you can open SMTP permissions to the appropriate client.) )   

8. Click OK and next to complete the configuration of the mailbox configuration file.   

9. Send a test message. Right-click Database Mail---Send Test e-mail. Enter the appropriate recipients (multiple people are separated by semicolons)  

10. E-Mail received as follows:  

11. Finally, add how to send mail via SQL script. (The previous configuration is required) EXEC Msdb.dbo.sp_send_dbmail@profile_name = ' Testdbemail ',@recipients = ' [email protected]; [Email protected] ',@subject = ' Test ',@body = ' Test sql Server sent email. '

Send mail using SQL Server

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.