Question

I'm trying to send email with activation link whenever a new user register on my website. but I'm getting activation failure after sending the email from localdb (SQL Server Express)

This is what I've tried

--Enabling Database Mail
sp_configure 'show advanced options',1
reconfigure
go  
sp_configure 'Database Mail XPs',1
reconfigure

--Creating a Profile
EXECUTE msdb.dbo.sysmail_add_profile_sp
@profile_name = 'Send_Mail',
@description = 'Sending Mail On Register and on some other activity.' ;

-- Create a Mail account for gmail. We have to use our company mail account.
EXECUTE msdb.dbo.sysmail_add_account_sp
@account_name = 'Send_Email_Register',
@email_address = 'abc@gmail.com',
@mailserver_name = 'smtp.gmail.com',
@port=587,
@enable_ssl=1,
@username='abc@gmail.com',
@password='Emailid password'

-- Adding the account to the profile
EXECUTE msdb.dbo.sysmail_add_profileaccount_sp
@profile_name = 'Send_Mail',
@account_name = 'Send_Email_Register',
@sequence_number =1 ;

-- Granting access to the profile to the DatabaseMailUserRole of MSDB
EXECUTE msdb.dbo.sysmail_add_principalprofile_sp
@profile_name = 'Send_Mail',
@principal_id = 0,
@is_default = 1 ;

--Sending Test Mail
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'Send_Mail',
@recipients = 'recipient@gmail.com',
@body = 'Database Mail Testing...',
@subject = 'Databas Mail from SQL Server';

--Verifying, check status column
select * from sysmail_allitems 
Was it helpful?

Solution

It looks like DBMail isn't supported on any of the Express instances. The feature breakdown can be seen at http://msdn.microsoft.com/en-us/library/cc645993.aspx#Add_DBServices, and a nice writeup of limitations for the SQL Server 2012 Express edition is in an answer to this thread.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top