I am getting following error while i am sending mail from SQL Server.
The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 1 (2019-01-01T08:16:39). Exception Message: Cannot send mails to mail server. (The specified string is not in the form required for an e-mail address.). )
I am writting the following code.
EXEC msdb.dbo.sp_send_dbmail
@profile_name ='Ikram_Email_Profile',
@recipients='mshams@al-jazeerapaints.com',
@subject='Test Message',
@body='This is the body of the test message.'
USE MASTER
GO
SP_CONFIGURE 'show advanced options', 1
RECONFIGURE WITH OVERRIDE
GO
SP_CONFIGURE 'Database Mail XPs', 1
RECONFIGURE WITH OVERRIDE
GO
SP_CONFIGURE 'show advanced options', 0
RECONFIGURE WITH OVERRIDE
GO
-- Creating Account for sending emails in SQL Server
USE MASTER
GO
EXEC msdb.dbo.sysmail_add_account_sp
@account_name = 'IkramShams_Mail_Account'
,@description = 'Send emails using SQL Server Stored Procedure'
,@email_address = 'testmailsp2018@gmail.com'
,@display_name = 'Mohammed Ikram'
,@replyto_address = 'testmailsp2018.com'
,@mailserver_name = 'smtp.gmail.com'
,@username = 'testmailsp2018.com'
,@password = 'GMAIL PASSWORD'
,@port = 587
,@enable_ssl = 1
GO
-- Creating Profile for sending email in SQL Server
EXEC msdb.dbo.sysmail_add_profile_sp
@profile_name = 'Ikram_Email_Profile'
,@description = 'Send emails using SQL Server Stored Procedure'
GO
Adding Account to Profile for sending email in SQL Server
EXEC msdb.dbo.sysmail_add_profileaccount_sp
@profile_name = 'Ikram_Email_Profile'
,@account_name = 'IkramShams_Mail_Account'
,@sequence_number = 1
GO