title: Powershell timeout when sending email
body: <p>I am trying to send a mail using powershell by making use of gmail smtp server. Here's my code snippet.</p>
  
  <pre><code>$sender = "user1@domain.com"
  $recipient = "user2@domain.com"
  $subject = "test"
  $body = "test text"
  $username = "user1@domain.com"
  $password = "password"
  
  $sc = new-object Net.Mail.SmtpClient("smtp.gmail.com", 465);
  $sc.EnableSsl = $true;
  $cred = New-Object System.Net.NetworkCredential($username,$password);
  $sc.Credentials = $cred;
  $emsg = new-Object System.Net.Mail.MailMessage($sender, $recipient, $subject, $body);
  $sc.Timeout = 180000
  $sc.Send($emsg);
  </code></pre>
  
  <p>Everytime I recieve a timeout, even if I have fixed the timeout value to 3 minutes(180 seconds). To be more precise, the error is </p>
  
  <pre><code>Exception calling "Send" with "1" argument(s): "The operation has timed out."
  At line:15 char:1
  + $sc.Send($emsg);
  + ~~~~~~~~~~~~~~~
  + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
  + FullyQualifiedErrorId : SmtpException
  </code></pre>
  
  <p>Have anyone experienced this issue before? Any suggestions or ideas would be really appreciated.</p>