{"id":2485,"date":"2023-08-09T18:06:50","date_gmt":"2023-08-09T16:06:50","guid":{"rendered":"https:\/\/www.hyperpac.de\/?p=2485"},"modified":"2023-08-09T18:06:50","modified_gmt":"2023-08-09T16:06:50","slug":"send-an-e-mail-via-powershell-script-using-send-mailmessage","status":"publish","type":"post","link":"https:\/\/www.hyperpac.de\/?p=2485","title":{"rendered":"Send an e-mail via Powershell script using Send-MailMessage"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>$password = ConvertTo-SecureString 'YourSmtpAccountPassword' -AsPlainText -Force\n$credential = New-Object System.Management.Automation.PSCredential ('YourSmtpUsername', $password)\n$smtpServer = \"smtp.yourdomain.com\"\n$smtpPort = 587\n \n$from = \"sender@yourdomain.com\"\n$to = \"recipient@yourdomain.com\"\n$subject = \"Your e-mail subject\"\n$body = \"Your e-mail text\"\n \nSend-MailMessage -SmtpServer $smtpServer -Port $smtpPort -UseSsl -From $from -To $to -Subject $subject -Body $body -Credential (Get-Credential $credential)<\/code><\/pre>\n\n\n\n<p>In order to run that as a powershell script you may need to run (at least) &#8220;<strong><code>Set-ExecutionPolicy RemoteSigned<\/code><\/strong>&#8221; in a privileged powershell. The script is configured to use a secure connection to your SMTP server (SSL\/TLS) on port 587. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>In order to run that as a powershell script you may need to run (at least) &#8220;Set-ExecutionPolicy RemoteSigned&#8221; in a privileged powershell. The script is configured to use a secure connection to your SMTP server (SSL\/TLS) on port 587.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[1227,1226,1228],"class_list":["post-2485","post","type-post","status-publish","format-standard","hentry","category-it_wordpres","tag-powershell","tag-script","tag-send-mailmessage"],"_links":{"self":[{"href":"https:\/\/www.hyperpac.de\/index.php?rest_route=\/wp\/v2\/posts\/2485","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hyperpac.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hyperpac.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hyperpac.de\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hyperpac.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2485"}],"version-history":[{"count":1,"href":"https:\/\/www.hyperpac.de\/index.php?rest_route=\/wp\/v2\/posts\/2485\/revisions"}],"predecessor-version":[{"id":2486,"href":"https:\/\/www.hyperpac.de\/index.php?rest_route=\/wp\/v2\/posts\/2485\/revisions\/2486"}],"wp:attachment":[{"href":"https:\/\/www.hyperpac.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2485"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hyperpac.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2485"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hyperpac.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2485"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}