Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

For our environment test we need to configure sp_send_dbmail to send emails only to certain recipients. Let's say a stored procedure executes the following code:

EXEC msdb.dbo.sp_send_dbmail
    @recipients=''; '',
    @body = @myBody,
    @subject = @mySubject,
    @profile_name =@myProfileName

I need the email to be sent only to, and not to Is there a way that i can configure this? Changing realusers email address won't do it for me.

share|improve this question

There is nothing built in that you could use already.

I would suggest creating a "wrapper" stored procedure for sp_send_dbmail, that accepts the exact same parameters and passes them through, with additional logic in place to check the @ recipients parameter that is passed against your exclusion list.

share|improve this answer
What I've done before, and the stored proc looks for developer groups etc to know whether a development box. – gbn Apr 26 '12 at 7:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.