I want to send mail using sql server and also receive mail in sql server
but It gives following error
The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 16 (2017-09-08T11:32:55). Exception Message: Cannot send mails to mail server. (Service not available, closing transmission channel. The server response was: Cannot connect to SMTP server 8.8.4.4 (8.8.4.4:25), connect error 10060).
)
What I have tried:
1)
EXECUTE msdb.dbo.sysmail_add_account_sp
@account_name = 'Asus01',
@description = 'Sent Mail using MSDB',
@email_address = '[EDIT: Removed user name]@gmail.com',
@display_name = 'Vinayak',
@username='[EDIT: Removed user name]@gmail.com',
@password='[EDIT: Removed password]',
@mailserver_name = 'google-public-dns-b.google.com'
when Fire query
select * from sysmail_account
output is
17 Asus01 Sent Mail using MSDB vinayak.paul2011@gmail.com Vinayak NULL 2017-09-08 12:31:30.853 sa
2)
EXECUTE msdb.dbo.sysmail_add_profile_sp
@profile_name = 'Asus01',
@description = 'Profile used to send mail'
-- select * from sysmail_profile
this query gives following output
13 Asus01 Profile used to send mail 2017-09-08 12:41:50.767 sa
3)
EXECUTE msdb.dbo.sysmail_add_profileaccount_sp
@profile_name = 'Asus01',
@account_name = 'Asus01',
@sequence_number = 1
--select * from sysmail_profileaccount
this query gives following output
13 17 1 2017-09-08 12:44:37.163 sa
4)
EXECUTE msdb.dbo.sysmail_add_principalprofile_sp
@profile_name = 'Asus01',
@principal_name = 'public',
@is_default = 1 ;
5)
Send Mail
exec msdb.dbo.sp_send_dbmail @profile_name = 'Asus01', @recipients = 'paulvinayak70@gmail.com', @subject = 'Mail Test', @body = 'Mail Sent Successfully', @body_format = 'text'
6) Fire query
select * from sysmail_allitems
select * from
fist in sent_status column it show
unsent
then after some time
sent_status column
display
failed