2
votes

In my web application I have created a mail sender class and set the configurations of web.config file like this:

 <mailSettings>
  <smtp deliveryMethod="PickupDirectoryFromIis">
    <network host="smtp.domain.com"
             port="587"
             userName="[email protected]"
             password="password"/>
  </smtp>
 </mailSettings>

This is sending email. But SQL Server database mail can not send mail with the same account info.

Only one difference is PickupDirectoryFromIis .

Is there any setting on exchange server?

In the SQL Server Logs the errors are following.

Message

The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 2 (2012-09-30T16:55:04). Exception Message: Cannot send mails to mail server. (The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.1 Client was not authenticated).

1

1 Answers

0
votes

Looks like this is a Authentication issue or port no issue.

Authentication Issue: —————————- Please make sure you have put the information as explained below:

Server name: smtp.gmail.com ( this is really important) port no: 587 ( on many website this is given as 465 which is wrong, use 587 ) Check : This server requires a secure connection Check Basic Authentication username: [email protected] ( should have gmail.com) password: XXXXXXXXXXXXX confirm password: confirm your password

Port No Issue: ——————– Make sure port 587 is opened in your machine if you are following above example. If you are using any other port number (usually its port 25) to set up database mail in your office, make sure you speak with your security team and ask them to unblock port 25. Once they unblock port 25, your databasemail will work.

Network Connectivity: —————————– Also check network connectivity from your machine, if you can connect to internet from your machine on which you are testing your database mail. To test, do the following

Start- Run- type cmd – Hit Enter Type ping gmail.com -t and then hit enter.

If output displays as Request timed out, it actually means there is network connectivity problem. Otherwise, your network connectivity is good.