1

How can I send the result of a Powershell (v 2.0) script by using IP address and port number of an SMTP server (e.g xxx.xxx.xx.xxx:xx) with anonymous authentication which does not require secure connection?

1 Answer 1

3

Here is a small script, don't forget, you are on the top of the .NET framework:

Param([string[]] $to = $(throw "Please Specify a destination !"), [string] $subject = "<No Subject>", [string] $body = $(throw "Pleasr specify a content !"), [string] $smtpHost = $(throw "Please specify a SMTP server !"), [string] $from = $(throw "Please specify from email address !") ) ## Message creation $email = New-Object System.Net.Mail.MailMessage ## Fill the fields foreach($mailTo in $to) { $email.To.Add($mailTo) } $email.From = $from $email.Subject = $subject $email.Body = $body ## Send the message $client = New-Object System.Net.Mail.SmtpClient $smtpHost $client.UseDefaultCredentials = $true $client.Send($email) 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.