0

I got this error when I specified multiple email addresses in reply_to

The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 7 (2014-08-19T12:54:35). Exception Message: Cannot send mails to mail server. (The specified string is not in the form required for an e-mail address.). )

here is the sql snippets

EXEC msdb..sp_send_dbmail             
@profile_name = 'Company',
@recipients = 'hi@sg.com',
@subject = 'PO delivery dates confirmation',
@body = 'test',
@body_format = 'HTML',
@importance = 'Normal',
@reply_to = '2@sg.com;3@sg.com'

I can't use distribution group because the reply_to is dynamic base on the query. what would be the work around for this?

  • 2
    You could look into handling mail with some other program outside of SQL Server, or using CC instead and hoping the recipient notices and replies all (no guarantee they'll obey the reply all in either case anyway). – Aaron Bertrand Aug 19 '14 at 20:11
4

@reply_to can only accept 1 email address. Its by design - see this connect.

The document reflects that as well.

[ @reply_to= ] 'reply_to' Is the value of the 'reply to address' of the email message. It accepts only one email address as a valid value. This is an optional parameter used to override the settings in the mail profile. This parameter is of type varchar(MAX). SMTP secuirty settings determine if these overrides are accepted. If no parameter is specified, the default is NULL.

-2

If you have to dynamically change the reply_to it seems like your going to have to wrap this sp_send_dbmail within a stored procedure and assign the single reply_to (based on some query) to a variable and use that vs. hardcoding the entries.

  • 1
    I think you missed the thrust of the problem - the OP wants sp_send_dbmail to accept multiple reply-to addresses in some cases, but it only accepts one. – Aaron Bertrand Aug 19 '14 at 21:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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