Gets the current server's public IP address and sends the message

Source: Internet
Author: User
Tags argumentlist

#mail  server configuration$smtpServer =  SMTP. Xxxx.com "$smtpuser  = " [email protected] "$smtpPassword  = " Oa123456 "#Create  the  mail message  $mail  = New-Object System.Net.Mail.MailMessage#Set the  addresses$mailaddress =  "[email protected]" $users  = @ () $users  = import-csv  -Path  "C:\user.csv" foreach  ($user  in  $users) {    # $user  =   $users  -split ', '      $mail .from = new-object  System.Net.Mail.MailAddress ($mailaddress)      $mailtoaddress  = $ user.mailaddresslist     $mail. To.add ($mailtoaddress)     }      #Detection  the Public IP     $ipurl  =  invoke-webrequest  ' http://myip.dnsomatic.com '  -UseBasicParsing     $PublicIp  =&nbSP; $ipurl .content      #set  send mail     $mail. subject =  "Powershell detection of demo server for the public  network ip address: "     $mail. priority =  "High"      $Nowtime = get-date -format  " yyyy. MM.DD-HH.MM.SS "     $mail. body =  "date \ Time: $Nowtime    Demo Server's public IP address: $publicip"      #send  the  message     $SMTP  = new-object system.net.mail.smtpclient - argumentlist  $smtpServer      $smtp. credentials = new-object system.net.networkcredential -argumentlist  $smtpuser, $ smtppassword     $SMTP. Send ($mail)

This article is from the "Paraquat Susan" blog, so be sure to keep this source http://suxin.blog.51cto.com/535505/1587513

Gets the current server's public IP address and sends the message

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.