Click here to Skip to main content
15,885,084 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to send using sql server

Error is


The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 6 (2017-09-07T14:01:30). Exception Message: Cannot send mails to mail server. (Service not available, closing transmission channel. The server response was: Cannot connect to SMTP server 204.11.56.48 (204.11.56.48:25), connect error 10060).
)


What I have tried:

			EXECUTE msdb.dbo.sysmail_add_account_sp
@account_name = 'MailTest',
@description = 'Sent Mail using SQL Server',
@email_address = 'imran@execsql.org',
@display_name = 'SQL Server-Mail Send',
@username='imran@execsql.org',
@password='your_password',
@mailserver_name = 'your_email_server_name'

--delete from sysmail_account
--select * from sysmail_account

EXECUTE msdb.dbo.sysmail_add_profile_sp
@profile_name = 'MailTest',
@description = 'Profile used to send mail'

--select * from sysmail_profile

EXECUTE msdb.dbo.sysmail_add_profileaccount_sp
@profile_name = 'MailTest',
@account_name = 'MailTest',
@sequence_number = 1

--select * from sysmail_profileaccount

EXECUTE msdb.dbo.sysmail_add_principalprofile_sp 
@profile_name = 'MailTest', 
@principal_name = 'public', 
@is_default = 1 ;




exec msdb.dbo.sp_send_dbmail 
@profile_name = 'MailTest', 
@recipients = 'paulvinayak70@gmail.com', 
@subject = 'Mail Test', 
@body = 'Mail Sent Successfully', 
@body_format = 'text'



but it gives error 
when I execute view 

select * from sysmail_allitems
at column send_status   it gives values as Failed


and description of error is as

The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 4 (2017-09-07T12:17:46). Exception Message: Cannot send mails to mail server. (Service not available, closing transmission channel. The server response was: Cannot connect to SMTP server 204.11.56.48 (204.11.56.48:25), connect error 10060).
)
Posted
Updated 7-Sep-17 2:35am
Comments
Mehdi Gholam 7-Sep-17 8:18am    
Try setting the @mailserver_name

1 solution

Error 10060 is
WSAETIMEDOUT:
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

So check if you have used the correct SMTP server address (is a SMTP server running on 204.11.56.48 and listening on port 25). Note also that the connection might be dropped by a Firewall.
 
Share this answer
 
Comments
paul_vin 7-Sep-17 14:48pm    
where I SHOULD MENTION SMTP server address in my code
Jochen Arndt 7-Sep-17 17:39pm    
As already mentioned by Mehdi Gholam: @mailserver_name

See https://technet.microsoft.com/en-us/library/ms182804(v=sql.105).aspx

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900