SQL Server 2005 Database Mail Setup and Configuration Scripts

By:   |   Comments (19)   |   Related: 1 | 2 | 3 | > Database Mail


Problem

One of the most welcome SQL Server 2005 enhancements over its predecessors is Database Mail.  Database Mail is built on the Simple Mail Transfer Protocol (SMTP) as compared to SQL Server 2000 Mail which used a buggy and temperamental MAPI client causing significant frustration.  Just like with everything else, every enhancement comes with its own learning curve.  If you're new to Database Mail in SQL 2005 it is quite easy to get lost somewhere between the Surface Area Configuration Tool (where Database Mail is enabled) and SQL Server Management Studio (where the settings for Database Mail configured).  I'll show you the basics of getting Database Mail configured for basic use in Management Studio and then show you a much quicker method via T-SQL.  You'll be able to get Database Mail running in under a minute once this script is customized for your environment.  At the end of this tip we will review a few of the most common stored procedures associated with Database Mail and compare them to their SQL Mail stored procedure equivalents.

Solution

Before SQL 2005 even had an official name and we were all referring to the product as Yukon, we've been told by Microsoft that the release would be "Secure by Default".  What does that mean exactly?  Well, what it means is that the base installation's configuration settings are as restrictive as possible.  You must explicitly enable features and services that provide additional functionality for SQL Server 2005, yet may expose it to unwanted intrusion.  The tool Microsoft has provided for this task is the SQL Server Surface Area Configuration.  This tip will focus on one of the features that is enabled via this tool: Database Mail.

SQL Server 2005 Surface Area Configuration - Database Mail

Step 1 - The enabling of this feature is simple enough; launch SQL Server Surface Area Configuration from your Start Menu:

configuration tools

Step 2 - Select Surface Area Configuration for Features:

surface area

Step 3 - Expand Database Engine, select Database Mail, and check the Enable Database Mail Stored Procedures checkbox.

area configuration

SQL Server 2005 Management Studio - Database Mail Configuration

At this point you've simply enabled the 25 system stored procedures that are used to perform email operations in SQL 2005 under the auspices of Database Mail.  It is now necessary to configure Database Mail for your environment.  For that we must move onto more familiar territory:  SQL Server management Studio (SSMS). 

Database Mail configuration in SQL Server 2005 Management Studio Step 1 - After launching SSMS, you'll need to connect to the server for which you wish to configure Database Mail.  Expand the Management folder, then right-click Database Mail and select Configure Database Mail.
database mail

Step 2 - Doing so will launch the Configure Database Mail Wizard.  It may look a little confusing at first, but once we step through it the script at the end of this tip will make more sense.

database mail

Step 3 - Since we're setting up Database Mail for the first time, select the Setup option as recommended.

select configuration task

Step 4 - The first step is to set up an email profile to be used with mail being sent from your SQL Server 2005 instance on this screen you will be required to create a profile name, description, and then assign an SMTP account to the profile.

new profile

Step 5 - Click the Add button to assign an SMTP account to the profile you're creating.  You may need to work with your Server Technicians and/or Security Teams to collect some of the information you'll need.  It's best to have this ahead of time so as not to hold up the process of configuring Database Mail.  You will need the account name, description, email address (both incoming and outgoing), display name, and SMTP server name for this account.  Be sure to confirm the port number with your Server Technicians as well.  Typically, the default of port 25 will work.  Select how you want to authenticate to the SMTP server and then click OK to proceed.

database mail account
new profile

Step 6 - You will notice that the account information is now listed.  You can set up multiple accounts for the Database Mail profile to allow for failover if you so choose.  Click Next to continue onto setting up security for the Database Mail profile.  I've already taken the liberty of setting this up as a Public Profile.  This means that all users of the SQL instance will have access to this Database Mail profile.  You have the option of creating Private Profiles that are only accessible to certain users of the instance.  In our environment we have a default Database Mail profile that is used across all SQL instances.  Your environment may differ.  A Future tip will outline creation and use of Private Database Mail Profiles. 

manage profile security

Step 7 - Once your form looks similar to this click Next to proceed to setting up your Database Mail system parameters, that form will look something like the one below.  I make no suggestions here.  You need to configure these settings to best-suit your environment.  In our environment I tend to allow for up to 5 retry attempts, but other than that I leave the defaults unchanged.

system parameters

Step 8 - It is finally time to finish up with the wizard.  Click Next for a summary of all the configuration settings you've made.  Once you've reviewed them you can proceed with running the underlying stored procedures that create .

complete the wizard
configuring

Database Mail T-SQL Commands

Congratulations, at this point you're now able to utilize Database Mail in the same manner as you utilized SQL Mail in previous versions of Microsoft SQL Server.  However, you may have noticed that stepping through the wizard was a little time-consuming.  I would rather script-out repetitive tasks rather than step through a wizard.  If you're like me, you support more than a single instance of Microsoft SQL Server with more instances coming online all the time.  That is why I maintain a SQL Server Solution that contains a listing of approximately a dozen scripts that I can run immediately after I install SQL Server 2005 and run through the Surface Area Configuration tool.  The last script I run executes four Database Mail stored procedures (enabled during our visit to the Surface Area Configuration tool) that cumulatively create the default profile I use across all my SQL Server instances, then sets up the associated account, security, parameters for that profile. 

SQL Server 2005 Database Mail Configuration Script

-- Create a Database Mail profile 			
EXECUTE msdb.dbo.sysmail_add_profile_sp 
@profile_name = 'SQL2005_Email_ProfileName',
@description = 'Notification service for SQL Server' ; 

-- Create a Database Mail account 
EXECUTE msdb.dbo.sysmail_add_account_sp
@account_name = 'SQL Server Notification Service', 
@description = 'SQL Server Notification Service', 
@email_address = 'john.doe@domain_name.com',
@replyto_address = 'john.doe@domain_name.com', 
@display_name = 'SQL Server Notification Service', 
@mailserver_name = 'smtpserver.domain_name.com' ; 

-- Add the account to the profile 
EXECUTE msdb.dbo.sysmail_add_profileaccount_sp
@profile_name = 'SQL2005_Email_ProfileName', 
@account_name = 'SQL Server Notification Service', 
@sequence_number =1 ; 

-- Grant access to the profile to the DBMailUsers role 
EXECUTE msdb.dbo.sysmail_add_principalprofile_sp 
@profile_name = 'SQL2005_Email_ProfileName',
@principal_id = 0, 
@is_default = 1 ; 

SELECT * FROM msdb.dbo.sysmail_profile
SELECT * FROM msdb.dbo.sysmail_account 

This is a simple process, much more simple than the wizard.  First, you pass the profile name and description into the dbo.sysmail_add_profile_sp system stored procedure to create the profile.  The next stored procedure, dbo.sysmail_add_account_sp creates the account that you'll assign to the profile.  The third system stored procedure you'll execute is dbo.sysmail_add_profileaccount_sp; assigning the account to the profile.  Finally, execute dbo.sysmail_add_principalprofile_sp to set the account priority and to assign the prodile to the DBMailUsers role on the SQL Server instance.  The SELECT statements that close out the statement block will confirm your settings executed successfully.  Twenty-eight lines of code and 2 seconds versus stepping through nine screens in the Configure Database Mail wizard.  You be the judge.

Additional Important Database Mail Stored Procedures

The first thing you'll notice when comparing SQL Mail versus Database Mail stored procedures is the sheer increase in available stored procedures that are now associated with the de-facto messaging component for SQL Server 2005.  These stored procedures give you unprecedented control over mail accounts, logs, tables, queues, and of course the composition and sending of query results to recipients.  Previously, when using SQL Mail, you had access to only a single stored procedure (sp_processmail, which in-turn called three different extended stored procedures and was declared a security risk by Microsoft Books Online) and a half-dozen extended stored procedures that had limited control over the SQL Mail inbox in addition to composing and sending query results to recipients.  By far, the most-important query for Database Mail is sp_send_dbmail.  This stored procedure affords you the ability to create a mail document, embed or attach query results, attach additional files, include message text, set a myriad of mail document properties and then send the mail message.  The SQL Mail counterpart to sp_send_dbmail is xp_sendmail.  All functionality from xp_sendmail exists in sp_send_dbmail, with some important differences as they relate to parameter data types.  The parameters for both mail message and query text are limited in SQL Mail to 8000 bytes each; sp_send_dbmail is able to bypass that limitation by making use of the nvarchar(max) data type that was first released in SQL Server 2005.   Additionally, Boolean parameters have been replaced by bit data types.  I've presented the syntax for each stored procedure and also summarized their differences below:

SQL Mail (Microsoft SQL 2000 and earlier)

		
xp_sendmail { [ @recipients= ] 'recipients [ ;...n ]' } 
[ ,[ @message= ] 'message' ] 
[ ,[ @query= ] 'query' ] 
[ ,[ @attachments= ] 'attachments [ ;...n ]' ] 
[ ,[ @copy_recipients= ] 'copy_recipients [ ;...n ]'
[ ,[ @blind_copy_recipients= ] 'blind_copy_recipients [ ;...n ]'
[ ,[ @subject= ] 'subject' ]
[ ,[ @type= ] 'type' ] 
[ ,[ @attach_results= ] 'attach_value' ]
[ ,[ @no_output= ] 'output_value' ] 
[ ,[ @no_header= ] 'header_value' ] 
[ ,[ @width= ] width ] 
[ ,[ @separator= ] 'separator' ] 
[ ,[ @echo_error= ] 'echo_value' ] 
[ ,[ @set_user= ] 'user' ] 
[ ,[ @dbuse= ] 'database' ]			

Database Mail (Microsoft SQL 2005)

	
sp_send_dbmail [ [ @profile_name = ] 'profile_name' ]
[ , [ @recipients = ] 'recipients [ ; ...n ]' ]
[ , [ @copy_recipients = ] 'copy_recipient [ ; ...n ]' ]
[ , [ @blind_copy_recipients = ] 'blind_copy_recipient [ ; ...n ]' ]
[ , [ @subject = ] 'subject' ] 
[ , [ @body = ] 'body' ] 
[ , [ @body_format = ] 'body_format' ]
[ , [ @importance = ] 'importance' ]
[ , [ @sensitivity = ] 'sensitivity' ]
[ , [ @file_attachments = ] 'attachment [ ; ...n ]' ]
[ , [ @query = ] 'query' ]
[ , [ @execute_query_database = ] 'execute_query_database' ]
[ , [ @attach_query_result_as_file = ] attach_query_result_as_file ]
[ , [ @query_attachment_filename = ] query_attachment_filename ]
[ , [ @query_result_header = ] query_result_header ]
[ , [ @query_result_width = ] query_result_width ]
[ , [ @query_result_separator = ] 'query_result_separator' ]
[ , [ @exclude_query_output = ] exclude_query_output ]
[ , [ @append_query_error = ] append_query_error ]
[ , [ @query_no_truncate = ] query_no_truncate ]
[ , [ @query_result_no_padding = ] query_result_no_padding ]
[ , [ @mailitem_id = ] mailitem_id ] [ OUTPUT ]			

Parameter Comparisons

Below outlines the parameter comparisons between xp_sendmail and sp_send_mail with some additional commentary:

SQL Mail (xp_sendmail) Parameter Database Mail (sp_send_dbmail) Parameter Notes
@set_user @profile_name SQL Mail: context query is run under.  DB Mail: DB mail profile to use
@recipients @recipients Semi-colon separated list of recipients
@copy_recipients @copy_recipients Semi-colon separated list of recipients
@blind_copy_recipients @blind_copy_recipients Semi-colon separated list of recipients
@subject @subject Subject of email
@message @body Email message, 8000 byte max in SQL Mail, varchar(max) in DB Mail
  @body_format Either 'Text' or 'HTML'
  @importance Either 'Low', 'Normal', or 'High'
  @sensitivity Either 'Normal', 'Personal', 'High', or 'Confidential'
@attachments @file_attachments Semicolon-separated list of file names for attachments as absolute file paths
@query @query Text of query to execute.  8000 byte max in SQL Mail, varchar(max) in DB Mail
@dbuse @execute_query_database Database to run query against
@attach_results @attach_query_result_as_file Attach query results as file?  Boolean in SQL Mail, Bit in DB Mail
  @query_attachment_filename Filename for the query results
@no_header @query_result_header Include column headers in the query results?  Boolean in SQL Mail, Bit in DB Mail
@width @query_result_width Line width, in characters for query results
@separator @query_result_separator Character to use for column delimiter
@echo_error @exclude_query_output Print query output messages?  Boolean in SQL Mail, Bit in DB Mail
  @append_query_error 0 or 1 to signify whether to send the email even if the query returns an error
  @query_no_truncate 0 or 1 to signify whether to truncate the query column results at 256 characters per column
  @query_result_no_padding 0 or 1 to signify whether to pad query results; default pads the results.
  @mailitem_id Returns the mailitem_id of the message
@no_output   TRUE or FALSE to determine whether the client session that called the sproc receives the output when the mail is sent.
@type   Signifies the type of MAPI mail message
Next Steps
  • Tweak T-SQL code provided to fit your environment. 
  • Examine the other Database Mail stored procedures and use them to add increased functionality and detail to this code. 
  • Add email notification functionality to your SQL Agent jobs without concern that MAPI will fail you and you'll miss important notifications. 
  • Stay tuned for more Database Mail tips.


sql server categories

sql server webinars

subscribe to mssqltips

sql server tutorials

sql server white papers

next tip



About the author
MSSQLTips author Tim Ford Tim Ford is a Senior Database Administrator with MindBody.

This author pledges the content of this article is based on professional experience and not AI generated.

View all my tips



Comments For This Article




Saturday, February 1, 2014 - 11:21:05 AM - neha Back To Top (29305)

database mail is not given under database engine 


Saturday, April 13, 2013 - 2:56:31 AM - Chirag Khunti Back To Top (23341)

Hi,

 

I am not getting option of Database mail in SQL Server 2005 Surface Area configuration under Database Enging node.

Can anyone plz guide me.

 


Tuesday, February 26, 2013 - 12:38:57 AM - mama Back To Top (22420)
8.       Generate script to send email confirmation with log files to email id.

Tuesday, February 26, 2013 - 12:38:07 AM - mama Back To Top (22419)
my question is Generate script to send email confirmation with log files to email id.
asap plzzz

Saturday, June 9, 2012 - 1:41:44 PM - Jeremy Kadlec Back To Top (17907)

Pinku Raj,

Have you checked out this post?

http://www.mssqltips.com/sqlservertip/2578/setup-sql-server-database-mail-to-use-a-gmail-hotmail-yahoo-or-aol-account/

HTH.

Thank you,
Jeremy Kadlec


Saturday, June 9, 2012 - 5:53:19 AM - Pinku Raj Back To Top (17899)

 

 

Hi,

I have configured as you said but i have configure the  Server = smtp.gmail.com and port = 25

 

When i tested the test mail the following error message is getting displayed in the log file.

The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 1 (2012-06-09T15:00:13). 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. io2sm10871828pbc.24).
),7844,5,,09-06-2012 15:00:13,sa

Can you please suggest a solution.


Thursday, June 7, 2012 - 7:24:34 AM - susmitha Back To Top (17831)

How to set off email functionality temporarily, please suggest.


Thursday, May 3, 2012 - 5:25:06 AM - Dinesh Back To Top (17250)

 

Nice work


Wednesday, March 28, 2012 - 9:55:24 AM - tosc Back To Top (16673)

Hi Praveen,

you mean something like this:

 

USE msdb
GO
Declare @TheResults varchar(max),
        @vbCrLf CHAR(2)
SET @vbCrLf = CHAR(13) + CHAR(10)       
SET @TheResults = '
use master
go
sp_configure ''show advanced options'',1
go
reconfigure with override
go
sp_configure ''Database Mail XPs'',1
--go
--sp_configure ''SQL Mail XPs'',0
go
reconfigure
go
'
SELECT @TheResults = @TheResults  + '
--#################################################################################################
-- BEGIN Mail Settings ' + p.name + '
--#################################################################################################
IF NOT EXISTS(SELECT * FROM msdb.dbo.sysmail_profile WHERE  name = ''' + p.name + ''')
  BEGIN
    --CREATE Profile [' + p.name + ']
    EXECUTE msdb.dbo.sysmail_add_profile_sp
      @profile_name = ''' + p.name + ''',
      @description  = ''' + ISNULL(p.description,'') + ''';
  END --IF EXISTS profile
  '
  +
  '
  IF NOT EXISTS(SELECT * FROM msdb.dbo.sysmail_account WHERE  name = ''' + a.name + ''')
  BEGIN
    --CREATE Account [' + a.name + ']
    EXECUTE msdb.dbo.sysmail_add_account_sp
    @account_name            = ' + CASE WHEN a.name                IS NULL THEN ' NULL ' ELSE + '''' + a.name                  + '''' END + ',
    @email_address           = ' + CASE WHEN a.email_address       IS NULL THEN ' NULL ' ELSE + '''' + a.email_address         + '''' END + ',
    @display_name            = ' + CASE WHEN a.display_name        IS NULL THEN ' NULL ' ELSE + '''' + a.display_name          + '''' END + ',
    @replyto_address         = ' + CASE WHEN a.replyto_address     IS NULL THEN ' NULL ' ELSE + '''' + a.replyto_address       + '''' END + ',
    @description             = ' + CASE WHEN a.description         IS NULL THEN ' NULL ' ELSE + '''' + a.description           + '''' END + ',
    @mailserver_name         = ' + CASE WHEN s.servername          IS NULL THEN ' NULL ' ELSE + '''' + s.servername            + '''' END + ',
    @mailserver_type         = ' + CASE WHEN s.servertype          IS NULL THEN ' NULL ' ELSE + '''' + s.servertype            + '''' END + ',
    @port                    = ' + CASE WHEN s.port                IS NULL THEN ' NULL ' ELSE + '''' + CONVERT(VARCHAR,s.port) + '''' END + ',
    @username                = ' + CASE WHEN c.credential_identity IS NULL THEN ' NULL ' ELSE + '''' + c.credential_identity   + '''' END + ',
    @password                = ''NotTheRealPassword'',
    @use_default_credentials = ' + CASE WHEN s.use_default_credentials = 1 THEN ' 1 ' ELSE ' 0 ' END + ',
    @enable_ssl              = ' + CASE WHEN s.enable_ssl = 1              THEN ' 1 ' ELSE ' 0 ' END + ';
  END --IF EXISTS  account
  '
  + '
IF NOT EXISTS(SELECT *
              FROM msdb.dbo.sysmail_profileaccount pa
                INNER JOIN msdb.dbo.sysmail_profile p ON pa.profile_id = p.profile_id
                INNER JOIN msdb.dbo.sysmail_account a ON pa.account_id = a.account_id 
              WHERE p.name = ''' + p.name + '''
                AND a.name = ''' + a.name + ''')
  BEGIN
    -- Associate Account [' + a.name + '] to Profile [' + p.name + ']
    EXECUTE msdb.dbo.sysmail_add_profileaccount_sp
      @profile_name = ''' + p.name + ''',
      @account_name = ''' + a.name + ''',
      @sequence_number = ' + CONVERT(VARCHAR,pa.sequence_number) + ' ;
  END --IF EXISTS associate accounts to profiles
--#################################################################################################
-- Drop Settings For ' + p.name + '
--#################################################################################################
/*
IF EXISTS(SELECT *
            FROM msdb.dbo.sysmail_profileaccount pa
              INNER JOIN msdb.dbo.sysmail_profile p ON pa.profile_id = p.profile_id
              INNER JOIN msdb.dbo.sysmail_account a ON pa.account_id = a.account_id 
            WHERE p.name = ''' + p.name + '''
              AND a.name = ''' + a.name + ''')
  BEGIN
    EXECUTE msdb.dbo.sysmail_delete_profileaccount_sp @profile_name = ''' + p.name + ''',@account_name = ''' + a.name + '''
  END
IF EXISTS(SELECT * FROM msdb.dbo.sysmail_account WHERE  name = ''' + a.name + ''')
  BEGIN
    EXECUTE msdb.dbo.sysmail_delete_account_sp @account_name = ''' + a.name + '''
  END
IF EXISTS(SELECT * FROM msdb.dbo.sysmail_profile WHERE  name = ''' + p.name + ''')
  BEGIN
    EXECUTE msdb.dbo.sysmail_delete_profile_sp @profile_name = ''' + p.name + '''
  END
*/
  '
FROM sysmail_profile p
INNER JOIN sysmail_profileaccount pa ON  p.profile_id = pa.profile_id
INNER JOIN sysmail_account a         ON pa.account_id = a.account_id
LEFT OUTER JOIN sysmail_server s     ON a.account_id = s.account_id
LEFT OUTER JOIN sys.credentials c    ON s.credential_id = c.credential_id

   ;WITH E01(N) AS (SELECT 1 UNION ALL SELECT 1 UNION ALL 
                    SELECT 1 UNION ALL SELECT 1 UNION ALL 
                    SELECT 1 UNION ALL SELECT 1 UNION ALL 
                    SELECT 1 UNION ALL SELECT 1 UNION ALL 
                    SELECT 1 UNION ALL SELECT 1), --         10 or 10E01 rows 
         E02(N) AS (SELECT 1 FROM E01 a, E01 b),  --        100 or 10E02 rows 
         E04(N) AS (SELECT 1 FROM E02 a, E02 b),  --     10,000 or 10E04 rows 
         E08(N) AS (SELECT 1 FROM E04 a, E04 b),  --100,000,000 or 10E08 rows 
         --E16(N) AS (SELECT 1 FROM E08 a, E08 b),  --10E16 or more rows than you'll EVER need, 
         Tally(N) AS (SELECT ROW_NUMBER() OVER (ORDER BY N) FROM E08), 
       ItemSplit( 
                 ItemOrder, 
                 Item 
                ) as ( 
                      SELECT N, 
                        SUBSTRING(@vbCrLf + @TheResults + @vbCrLf,N + DATALENGTH(@vbCrLf),CHARINDEX(@vbCrLf,@vbCrLf + @TheResults + @vbCrLf,N + DATALENGTH(@vbCrLf)) - N - DATALENGTH(@vbCrLf)) 
                      FROM Tally 
                      WHERE N < DATALENGTH(@vbCrLf + @TheResults) 
                      --WHERE N < DATALENGTH(@vbCrLf + @INPUT) -- REMOVED added @vbCrLf 
                        AND SUBSTRING(@vbCrLf + @TheResults + @vbCrLf,N,DATALENGTH(@vbCrLf)) = @vbCrLf --Notice how we find the delimiter 
                     ) 
  select 
    row_number() over (order by ItemOrder) as ItemID, 
    Item 
  from ItemSplit 

I wish you a nice day,

tosc


Wednesday, March 28, 2012 - 9:01:13 AM - Praveen Back To Top (16670)

Hi,

i have many datbase mail profiles configured on my Production server, what i would like to know is that is there any way to generate script of existing profiles.

Regards,

Praveen


Tuesday, March 13, 2012 - 5:03:00 PM - Glen Back To Top (16365)

if it is possible to send sql agent job output(message) thru notification email?

i.e. I have a job to list files in a directory (dir G:\sqlbackup) and I set notification to send email to me when job is complete. but I want to see the output.

Thanks in advance.

Glen


Tuesday, March 8, 2011 - 1:18:34 PM - LY Back To Top (13147)

Thanks very much for the step by step instruction. I have a question to ask here:

When send email is failed because the email address is not reachable (wrong), how to get a notification from SQL server to a designated email address such as administrator?


Saturday, March 27, 2010 - 8:12:04 PM - Install software Back To Top (5131)
Install software in an operating system does not require any special skills. However, you must know the basics prior to attempting it. First and the foremost thing is that the installation depends upon the operating system being used and the program being installed. However, you should follow the guidelines mentioned in the software cover. .

Tuesday, April 7, 2009 - 5:19:54 AM - mcates Back To Top (3145)

First, I found this post absolutely helpful it was so clear and easy to follow.  And the best part was the t-sql at the end that helps explain and teach you how to do it through a script. 

Second, there are two additional steps to acutally get SQL 2005 to send you email alerts about your jobs.

   1.  You must edit the properties of the SQLAgent and enable database mail and set the mail profile.

   2. You must create an operator to use to configure the maintenance plans to send the email alert to.

 Finally I would like to see an update of the post to included these two step, paticularlry the T-SQL code so that I can create a scipt to do all of it. 

 I have to say that this was a fantastic post and very helpful in that you show the wizard steps and the more complex t-sql steps and I found that portion wonderful and will use it in the future....

 Regards,

Mike


Thursday, February 19, 2009 - 1:47:54 PM - admin Back To Top (2797)

Try to send an internal email that has the same domain as the mail server you used for your Database Mail profile. 

It is possible there are settings in the mail server that are not allowing you to push mail outside of the domain.


Thursday, February 19, 2009 - 9:02:02 AM - santosh Back To Top (2794)

check the windows authentication instead of anonymous while creating an account.Hope this will help.


Thursday, July 3, 2008 - 3:21:36 AM - skyline666 Back To Top (1347)

[quote user="ravi1217"]I have configured the settings what you told. When i tested the test mail the following error message is getting displayed in the log file.

The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 6 (2008-04-24T18:55:18). Exception Message: Cannot send mails to mail server. (Mailbox unavailable. The server response was: 5.7.1 Unable to relay for ).
)

Can you please suggest a solution.

I tried wether smtp connection is working or not. It's working.[/quote]

Hi,

 On http://www.databasejournal.com/features/mssql/article.php/3626056 (a similar run through of how to set up database mail), an error was displayed that is similar to yours and shows how to solve it.  The error shown is about half way down the page, and the solution given is to open up port 25 to allow emails to be sent.

 HTH


Thursday, May 1, 2008 - 11:28:22 PM - tosc Back To Top (934)

Hi ravi1217,

 are you sure, that you choose the right smtp authentication? plz. tell us your configuration.


Thursday, April 24, 2008 - 7:18:07 AM - ravi1217 Back To Top (909)

I have configured the settings what you told. When i tested the test mail the following error message is getting displayed in the log file.

The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 6 (2008-04-24T18:55:18). Exception Message: Cannot send mails to mail server. (Mailbox unavailable. The server response was: 5.7.1 Unable to relay for).
)

Can you please suggest a solution.

I tried wether smtp connection is working or not. It's working.















get free sql tips
agree to terms