Sql-server – How to temporarily disable sp_send_dbmail

sql serversql-server-2008

I have just taken over responsibility for a SQL 2000 system which made heavy use of xp_sendmail.

We are in the process of upgrading to SQL Server 2008 R2 and I have implemented sp_send_dbmail.

We are currently performing user acceptance testing on the new SQL Server. The application sends out many emails directly to our customers. Since our test database is a copy of our live database, there are many valid customer email addresses in our test database. Is there a way to either temporarily redirect the emails or shut down the Database Mail service, without impacting our testing?

Best Answer

USE msdb
GO
EXECUTE dbo.sysmail_stop_sp
GO

Will stop the server from sending mail. EXECUTE dbo.sysmail_start_sp will start up the service again.