Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sp_send_dbmail: FROM_ADDRESS

I am using SQL Server 2008 R2. When I execute sp_send_dbmail I can't change the FROM_ADDRESS from the default one that our DBA specified. Why is there this parameter if it doesn't work? How do I specify a "custom" FROM_ADDRESS?

like image 880
Denis Avatar asked Apr 15 '13 20:04

Denis


People also ask

What is Sp_send_dbmail?

Sends an e-mail message to the specified recipients. The message may include a query result set, file attachments, or both. When mail is successfully placed in the Database Mail queue, sp_send_dbmail returns the mailitem_id of the message. This stored procedure is in the msdb database.

How do I check SQL Server mail logs?

The Database Mail external program logs activity and displays the log through the Windows Application Event Log and the sysmail_event_log view in the msdb database. To check the status of an e-mail message, run a query against this view.

How can I tell if Dbmail is enabled?

First to check to make sure that Database Mail is enabled. Look in 'sys. configurations' for the setting Database Mail XPs, and if it is set to 0, Database Mail is not enabled. The value column shows '0', so Database Mail is off.

What is SP_send_dbmail?

sp_send_dbmail (Transact-SQL) Sends an e-mail message to the specified recipients. The message may include a query result set, file attachments, or both. When mail is successfully placed in the Database Mail queue, sp_send_dbmail returns the mailitem_id of the message. This stored procedure is in the msdb database.

Why does SP_send_dbmail block access to procedure DBO?

Msg 15281, Level 16, State 1, Procedure sp_send_dbmail, Line 0 SQL Server blocked access to procedure 'dbo.sp_send_dbmail' of component 'Database Mail XPs' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'Database Mail XPs' by using sp_configure.

Is SP_send_dbmail blocked in MSG 15281?

Let's fire up SQL Server and give it a try: Msg 15281, Level 16, State 1, Procedure sp_send_dbmail, Line 0 SQL Server blocked access to procedure 'dbo.sp_send_dbmail' of component 'Database Mail XPs' because this component is turned off as part of the security configuration for this server.

How do I start and send database mail?

To start Database Mail, use sysmail_start_sp. When **@profile** is not specified, sp_send_dbmail uses a default profile. If the user sending the e-mail message has a default private profile, Database Mail uses that profile. If the user has no default private profile, sp_send_dbmail uses the default public profile.


1 Answers

Did you try in this exact format:

@from_address = 'custom display name <custom_address@your_domain.com>'

? Also, according to the documentation, you need to be sure that your SMTP server will accept an override - it may be getting rejected at the server and has nothing to do with your code.

Finally, it is possible that under 2005 compatibility mode, the @profile_name will not be visible. (I can't confirm this right now, but this was a new parameter added in SQL Server 2008.)

like image 143
Aaron Bertrand Avatar answered Sep 23 '22 03:09

Aaron Bertrand