Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Unable to send mail

Author  Topic 

yaman
Posting Yak Master

213 Posts

Posted - 2012-03-21 : 15:00:21
Hello Sir ,

I am trying to send mail from sql server 2008 .

I got "The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 2 (2012-03-22T11:55:21). Exception Message: Could not connect to mail server. (No such host is known). )" this message .


I follow this step to create profile -




EXEC sp_configure 'show advanced options', 1
GO
RECONFIGURE WITH OVERRIDE
GO
EXEC sp_configure 'cmdshell', 1
GO
RECONFIGURE WITH OVERRIDE
GO
EXEC sp_configure 'show advanced options', 0 --*
GO




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
---------------------------2nd step---------------------------

EXECUTE msdb.dbo.sysmail_add_account_sp
@account_name = 'MyMailAccount',
@description = 'Mail account for Database Mail',
@email_address = 'test@domain.com',
@display_name = 'MyAccount',
@username='test@domain.com',
@password='password',
@mailserver_name = 'domain.com'

-------------------------3rd step--------------------
EXECUTE msdb.dbo.sysmail_add_profile_sp
@profile_name = 'MyMailProfile',
@description = 'Profile used for database mail'
----------------4rth stpe--------------------

EXECUTE msdb.dbo.sysmail_add_profileaccount_sp
@profile_name = 'MyMailProfile',
@account_name = 'MyMailAccount',
@sequence_number = 1
----------------------5th stpe-----------------

EXECUTE msdb.dbo.sysmail_add_principalprofile_sp
@profile_name = 'MyMailProfile',
@principal_name = 'public',
@is_default = 1 ;

------------------------6th step-----------------------

declare @body1 varchar(100)
set @body1 = 'Server :'+@@servername+ 'My First Database Email'
EXEC msdb.dbo.sp_send_dbmail @recipients='test@domain.com',
@subject = 'My Mail Test',
@body = @body1,
@body_format = 'HTML';


Please help me out Sir .

Thanks .








Yaman

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-03-21 : 15:05:21
have you set up profile correctly?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

yaman
Posting Yak Master

213 Posts

Posted - 2012-03-21 : 15:07:05
Yes Sir .

I follow all steps correctly.Sir Is there any user role problem .

Yaman
Go to Top of Page
   

- Advertisement -