Setting up Database Mail
This recipe demonstrates how to set up Database Mail programmatically using PowerShell.
Getting ready
The assumption in this recipe is that Database Mail is not yet configured on your instance.
These are the settings we will use for this recipe:
Setting |
Value |
---|---|
Mail Server |
|
Mail Server Port |
|
E-mail address for Database Mail profile |
|
SMTP authentication |
Basic authentication |
Credentials for e-mail address |
Username is Password is |
How to do it...
To set up Database Mail, follow these steps:
- Open PowerShell ISE as administrator.
- Import the SQLPS module and create a new SMO Server object:
#import SQL Server module Import-Module SQLPS ...
Get SQL Server 2014 with PowerShell v5 Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.