{"id":5272,"date":"2021-08-25T23:49:48","date_gmt":"2021-08-25T23:49:48","guid":{"rendered":"https:\/\/pariswells.com\/blog\/?p=5272"},"modified":"2022-12-02T03:44:39","modified_gmt":"2022-12-02T03:44:39","slug":"using-powershell-to-send-emails-via-mimecast","status":"publish","type":"post","link":"https:\/\/pariswells.com\/blog\/research\/using-powershell-to-send-emails-via-mimecast","title":{"rendered":"Using Powershell to Send Emails via Mimecast"},"content":{"rendered":"\n<p>You can send emails via Mimecast instead of 365 , so you don\u2019t need a licensed 365 user.<\/p>\n\n\n\n<p>Login and enable SMTP Email submissions for that user<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"767\" height=\"399\" src=\"https:\/\/pariswells.com\/blog\/wp-content\/uploads\/2021\/08\/img_6126d65bb9d16.png\" alt=\"\" class=\"wp-image-5273 img-responsive\" srcset=\"https:\/\/pariswells.com\/blog\/wp-content\/uploads\/2021\/08\/img_6126d65bb9d16.png 767w, https:\/\/pariswells.com\/blog\/wp-content\/uploads\/2021\/08\/img_6126d65bb9d16-300x156.png 300w\" sizes=\"auto, (max-width: 767px) 100vw, 767px\" \/><\/figure>\n\n\n\n<p>Use the users Cloud password and email address for Auth<\/p>\n\n\n<div class=\"wp-block-wab-pastacode\">\n\t<div class=\"code-embed-wrapper\"> <pre class=\"language-markup code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-markup code-embed-code\">$creds = get-credential<br\/><br\/>Send-MailMessage -From clouduser@domain.com -To test@test.com -Subject &quot;Test Email&quot; -Body &quot;Test SMTP Service from Powershell on Port 587&quot; -SmtpServer au-smtp-outbound-1.mimecast.com -Credential $creds -UseSsl -Port 587<\/code><\/pre> <div class=\"code-embed-infos\"> <\/div> <\/div><\/div>\n\n\n\n<p>If you see<\/p>\n\n\n\n<p><strong>Send-MailMessage : Unable to read data from the transport connection: net_io_connectionclosed<\/strong><\/p>\n\n\n\n<p>You need to create an Authentication profile with 2fa disabled , and apply it to that user via Application Settings<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1169\" height=\"437\" src=\"https:\/\/pariswells.com\/blog\/wp-content\/uploads\/2021\/08\/img_6126d6ba40276.png\" alt=\"\" class=\"wp-image-5274 img-responsive\" srcset=\"https:\/\/pariswells.com\/blog\/wp-content\/uploads\/2021\/08\/img_6126d6ba40276.png 1169w, https:\/\/pariswells.com\/blog\/wp-content\/uploads\/2021\/08\/img_6126d6ba40276-300x112.png 300w, https:\/\/pariswells.com\/blog\/wp-content\/uploads\/2021\/08\/img_6126d6ba40276-1024x383.png 1024w, https:\/\/pariswells.com\/blog\/wp-content\/uploads\/2021\/08\/img_6126d6ba40276-768x287.png 768w\" sizes=\"auto, (max-width: 1169px) 100vw, 1169px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1197\" height=\"304\" src=\"https:\/\/pariswells.com\/blog\/wp-content\/uploads\/2021\/08\/img_6126d716367fd.png\" alt=\"\" class=\"wp-image-5275 img-responsive\" srcset=\"https:\/\/pariswells.com\/blog\/wp-content\/uploads\/2021\/08\/img_6126d716367fd.png 1197w, https:\/\/pariswells.com\/blog\/wp-content\/uploads\/2021\/08\/img_6126d716367fd-300x76.png 300w, https:\/\/pariswells.com\/blog\/wp-content\/uploads\/2021\/08\/img_6126d716367fd-1024x260.png 1024w, https:\/\/pariswells.com\/blog\/wp-content\/uploads\/2021\/08\/img_6126d716367fd-768x195.png 768w\" sizes=\"auto, (max-width: 1197px) 100vw, 1197px\" \/><\/figure>\n\n\n\n<p><strong>\u201cSend-MailMessage : A call to SSPI failed, see inner exception\u201d<\/strong><\/p>\n\n\n\n<p>Trying to send email comes back with this error , you need to change TLS1.2<\/p>\n\n\n\n<p><strong>\u2018ServicePointManager.SecurityProtocol\u2019 is not recognized as the name<\/strong><\/p>\n\n\n\n<p>Trying to use<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;\n<\/code><\/pre>\n\n\n\n<p>to Force TLS 1.2 doesn\u2019t work&nbsp;<\/p>\n\n\n\n<p>Use&nbsp;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># Enable TLS 1.2 as Security Protocol\n[Net.ServicePointManager]::SecurityProtocol = `\n    [Net.SecurityProtocolType]::Tls12 ;<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>You can send emails via Mimecast instead of 365 , so you don\u2019t need a licensed 365 user. Login and enable SMTP Email submissions for that user [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[3659,3660,1797,3568,576,3661,1176],"class_list":["post-5272","post","type-post","status-publish","format-standard","hentry","category-research","tag-servicepointmanager-securityprotocol-is-not-recognized-as-the-name","tag-send-mailmessage-a-call-to-sspi-failed","tag-mimecast","tag-net_io_connectionclosed","tag-powershell","tag-see-inner-exception","tag-smtp"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/5272","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/comments?post=5272"}],"version-history":[{"count":3,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/5272\/revisions"}],"predecessor-version":[{"id":6480,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/5272\/revisions\/6480"}],"wp:attachment":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/media?parent=5272"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/categories?post=5272"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/tags?post=5272"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}