Take the 2-minute tour ×
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.

I'm sending emails directly to Microsoft Outlook accounts from SQL Server 2008. Everything is fine, email was sent. Only problem is that in the header of the email the SQL Server name is embedded.

I've tried specifying the @from_address when executing the mail sending in DB but the sql server name is still there in the email's header. I don't want my recipients to see the sql server name in the header.

Is there a way to block this?

Thanks much!

share|improve this question

migrated from stackoverflow.com Dec 16 '11 at 13:05

This question came from our site for professional and enthusiast programmers.

2  
SMTP security settings determine if these overrides are accepted - @from_address may be ignored because of the mail server settings. –  Marek Grzenkowicz Dec 16 '11 at 11:12
add comment

2 Answers 2

Try creating a new database mail profile and database mail account. Put the email address you desire as the name of the new mail account. Then use the profile when calling the stored procedure to send email: EXEC msdb.dbo.sp_send_dbmail
@profile_name = "DB Mail Profile"

Cheers!

share|improve this answer
add comment

You need to manage the information for your Database Mail Configurations. There are two things to be concerned with:

  • Database Mail Profiles
  • Database Mail Accounts

The From and Reply-To email addresses are stored as part of the database mail account. The account is, in turn, associated with a profile. Multiple accounts can be associated with a profile and multiple profiles can exist. One profile will be set as a default for use by the mail processes and that's likely where your From address is being taken from.

You can view your mail information using the following:

SELECT
    p.name [Profile Name]
    ,p.description [Profile Description]
    ,pp.is_default
    ,a.name [Account Name]
    ,a.display_name [Account Display Name]
    ,a.email_address [From Address]
    ,a.replyto_address [ReplyTo Address]
FROM
    msdb.dbo.sysmail_profile p
    JOIN msdb.dbo.sysmail_principalprofile pp ON (p.profile_id = pp.profile_id)
    JOIN msdb.dbo.sysmail_profileaccount pa ON (p.profile_id = pa.profile_id)
    JOIN msdb.dbo.sysmail_account a ON (pa.account_id = a.account_id);

To resolve your issue, you have three approaches:

  • Update your From address for the account associated to your current default profile:

    exec sysmail_update_account_sp @account_id=[account ID], @email_address=[From address]

  • Create a new profile and make it your default, then add an appropriate account with the necessary information.

  • Create a new profile, add your new information, and call it explicitly using exec sp_send_dbmail @profile_name='[profile name]'

You can manage all this using the Database Mail Stored Procedures or using SSMS under Management->Database Mail:

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

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