title: Unable to send email from SQL Server
body: <p>I am trying to send an email from SQL Server to Trigger. I have performed as per the guidance in <a href="http://surajpassion.in/sending-email-using-stored-procedures-in-sql-server/" rel="nofollow noreferrer">this</a> blog. Whenever I am trying as email, I am getting an error.</p>
  
  <pre><code>EXEC msdb.dbo.sysmail_add_account_sp
      @account_name = 'ChandreshTestAccount'
    , @description = 'Sending email from test account'
    , @email_address = 'chandresh.cmk@gmail.com'
    , @display_name = 'No-Reply'
    , @replyto_address = 'chandresh.cmk@gmail.com'
    , @mailserver_name = 'smtp.gmail.com'
    , @port = 25
    , @username = 'chandresh.cmk@gmail.com'
    , @password = 'xxxxxxx'
  Go
  </code></pre>
  
  <blockquote>
    <p>Error: The mail could not be sent to the recipients because of the
    mail server failure. (Sending Mail using Account 6
    (2017-02-02T14:24:46). Exception Message: Could not connect to mail
    server. (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 74.125.68.109:25).
    )</p>
  </blockquote>
  
  <p>Then I have tried to change the port number 587 and got the below error.</p>
  
  <blockquote>
    <p>The mail could not be sent to the recipients because of the mail
    server failure. (Sending Mail using Account 5 (2017-02-02T14:28:22).
    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.0 Must issue a STARTTLS command first.
    n8sm30283000pgc.16 - gsmtp). )</p>
  </blockquote>
  
  <p>Then again I have tried to change the port number 465 and got the below error</p>
  
  <blockquote>
    <p>The mail could not be sent to the recipients because of the mail
    server failure. (Sending Mail using Account 4 (2017-02-02T14:28:19).
    Exception Message: Cannot send mails to mail server. (Failure sending
    mail.). )</p>
  </blockquote>
  
  <p>Is there anything I am missing?
  Note: I am trying this in Local Machine and I am able to send email from <code>C#</code> code with <code>Port 25</code></p>
  
  <p>Thank You.</p>