Chapter 2: Before you Create any Maintenance Plans… 31 Figure 2.2: The Database Mail Configuration Wizard does several different tasks. To set up Database Mail for use by the Maintenance Wizard, select the option Set up Database Mail by performing the following tasks. The wizard even lists the three tasks that need to be completed to set up Database Mail, which are explained shortly. Click on Next to continue. If database mail has not yet been enabled for this SQL Server instance, then you will see the screen shown in Figure 2.3. If it has been enabled, you won't see the screen. Figure 2.3: Before you can configure Database Mail, you must first enable it. Chapter 2: Before you Create any Maintenance Plans… 32 Assuming that Database Mail has not been turned on for this SQL Server instance, and you see the above screen, click Yes, and Database Mail will be enabled. The next screen, shown in Figure 2.4, will prompt you to create a Database Mail profile. A profile is a collection of one or more SMTP accounts that can be used by SQL Server to send messages. In other words, when SQL Server wants to send a message, the message is sent to the profile, and then the profile is responsible for seeing that the e-mail is actually delivered. For fault tolerance, a profile can include more than one SMTP account. For example, if the profile tries to send an e-mail using one SMTP account, but it is not working, then the profile will attempt to send the e-mail using a second SMTP account, assuming one is available. Profiles can also be used as a security measure, either allowing or preventing someone from using it to send mail. Figure 2.4: The first step when configuring Database Mail is to create a new profile. To create a new profile, you must enter a profile name, an optional description, and then add and configure one or more SMTP accounts. In this example, we will create and configure a single SMTP account. Chapter 2: Before you Create any Maintenance Plans… 33 Multiple mail profiles Database Mail can have multiple profiles to meet a wide variety of fault tolerance and security needs. Here, you just need a single profile for use by your Maintenance Plans. Enter a descriptive Profile name, such as "Maintenance Plans." If your SQL Server instance has multiple mail profiles, then you'll probably want to enter a description of the intended use of this particular profile, so you don't get them confused. Next, create and configure the SMTP account that will be used by Database Mail to send the e-mails from your Maintenance Plan. To create and configure a SMTP account, click on the Add… button, and the New Database Mail Account screen appears, as shown in Figure 2.5. Figure 2.5: You will probably have to track down your SMTP server settings before you can complete this screen. If you have never set up an e-mail client before, this screen might seem a little confusing. Essentially, you have to tell Database Mail what mail server it should use to deliver e-mail messages from your Maintenance Plans. If you're unsure, send the screenshot shown in Figure 2.5 to your organization's e-mail administrator, so he or she will know what SMTP settings you need. Chapter 2: Before you Create any Maintenance Plans… 34 When you ask the e-mail administrator for the SMTP settings, you also need to request that a special e-mail account be set up for use by SQL Server. For example, you might have an account set up called sqlserver@myorganization.com or sqlserveragent@ or maintenanceplan@ or some other descriptive name, so that when you receive an e-mail from Database Mail, you will know where it came from. Let's take a look at each option, starting with the basic attributes of the SMTP account. • Account name. The SMTP account must have a name so that it can be distinguished from other SMTP accounts used in the same profile. Since you are creating only a single SMTP account for your profile, what you call it is not very important. However, should you decide to have two SMTP accounts, for fault tolerance purposes, then you'd need to name them descriptively so that you can easily distinguish one from another. For example, you could use the name of the SMTP server as the account name, as that is a good way to distinguish one SMTP account from another. • Description. This optional textbox can be left empty, or you can use it to help document your settings. For example, you might enter the name of the person who provided the SMTP settings, so you know who to go back to in the event of any problems. • Outgoing Mail Server (SMTP). This specifies attributes of the SMTP Server that will be sending the e-mail, including these six options: • E-mail address – the e-mail account that has been set up for use with SQL Server's database mail (for example, sqlserver@myorganization.com). • Display name – the display name of the above e-mail address that is shown as part of an e-mail. You will probably want to give it the same name as the user part of the e-mail address, such as "SQL Server," although you can use any name you choose that will remind you where the e-mail comes from. • Reply e-mail – the e-mail address used if someone should reply to an e-mail sent from the e-mail address entered above. Database Mail can't respond to e-mails it receives, so you can either leave this option empty, or add your own e-mail address, just in case someone should respond to an e-mail received from SQL Server. • Server name – the name of the SMTP mail server. It generally looks something like mail.myorganization.com. Chapter 2: Before you Create any Maintenance Plans… 35 • Port number – the port number used by your organization's SMTP server. E-mail servers communicate through specific TCP/IP ports, and the default port number, 25, is the one most commonly used, but it may not be the one your company uses, so be sure to check. • This server requires a secure connection (SSL) – some SMTP servers require that SSL be turned on for additional security. Only select this option if you are instructed to do so. The lower half of the screen is where we specify the SMTP Authentication options. In most cases, before an SMTP server will accept an e-mail, the sender must log on to the SMTP server with an authorized e-mail account. This is done to prevent spammers from accessing the SMTP server and using it. Find out which authentication model your organization uses, and complete the appropriate information, as follows: • Windows Authentication using Database Engine service credentials: This option is not commonly used but, if it is, you have to ensure that the account used for the Database Engine service has permission to route mail to the SMTP server. • Basic authentication: This is the most common method of authentication, and requires you to provide a user name and password. In most cases, the user name will be the e-mail address you entered above, and the password will be the password used for this e-mail address. • Anonymous authentication: This option is rarely used because it allows anyone to access the SMTP server. Having entered values for all of the settings, the screen will look similar to that shown in Figure 2.6. . prompt you to create a Database Mail profile. A profile is a collection of one or more SMTP accounts that can be used by SQL Server to send messages. In other words, when SQL Server wants to send. e-mail account be set up for use by SQL Server. For example, you might have an account set up called sqlserver@myorganization.com or sqlserveragent@ or maintenanceplan@ or some other descriptive. you have to tell Database Mail what mail server it should use to deliver e-mail messages from your Maintenance Plans. If you're unsure, send the screenshot shown in Figure 2.5 to your organization's