Tuesday, November 19, 2013

Script To Test Exchange SMTP operations

How To Test Exchange SMTP operations


In this post we are going to use a script to test SMTP operations without using telnet.

My domain : QNET.COM

From the below script you can notice I'm using ABC.COM from address, QNET.COM my domain, EXC2010 my smtp server and sending an attachment (TEST.txt) with contents included in body of the message

PowerShell Script used for this test.


###############################################################################

###########Define Variables########

$fromaddress = "LogBackup@abc.com"
$toaddress = "EXC10USER5@qnet.com"
$bccaddress = "2013Admin@qnet.com"
$CCaddress = "Administrator@qnet.com"
$Subject = "Event Log Archive Status"
$body = "Event Log Archive Completed with attached Servers not reachable..."
$attachment = "C:\sendemail\test.txt"
$smtpserver = "EXC2010.QNET.COM"

####################################

$message = new-object System.Net.Mail.MailMessage
$message.From = $fromaddress
$message.To.Add($toaddress)
$message.CC.Add($CCaddress)
$message.Bcc.Add($bccaddress)
$message.IsBodyHtml = $True
$message.Subject = $Subject
$attach = new-object Net.Mail.Attachment($attachment)
$message.Attachments.Add($attach)
$message.body = $body
$smtp = new-object Net.Mail.SmtpClient($smtpserver)
$smtp.Send($message)

#################################################################################





Thank you for visiting my blog

Please update your comments or feedback.

Contact me @: exctech2013@gmail.com

No comments:

Post a Comment