Subscribe

error in sending mail

I tried to create a command to send mail with following code.When i test the command it showing following error

 

Capture5.JPG

$SENDER="abc@netapp.com"
$MAIL_SERVER="10.57.159.114"
$NOTIFY_ID="abc@netapp.com"
$SUBJECT="This is Subject"
$MAIL_BODY="This is testing only"


$SMTP = new-object Net.Mail.SmtpClient(${MAIL_SERVER})
$MSG =New-Object System.Net.Mail.MailMessage "${SENDER}", "${NOTIFY_ID}", "${SUBJECT}", "${MAIL_BODY}"

$SMTP.Send($MSG)

Re: error in sending mail

Hi Aswani,

 

Did you try cloning the certified 'send email' command and taking it from there ?

 

Also, do you know how to send a csv as attachment in a command ? Was just trying to investigate that.

 

Thanks!

Re: error in sending mail

I tried with the certified sendmail command but getting same error .

Capture3.JPG

 

 

My smtp server is working fine when i ping that.

Re: error in sending mail

In the snapshot you sent you were missing a p in netapp and the smtp port was not 25 , but let suppose that is not the problem.

 

I would start with a telnet the smpt server on port 25 and manually try to send an email to see if the wfa server is authorized to send emails on the smtp sever.

 

http://www.port25.com/how-to-check-an-smtp-connection-with-a-manual-telnet-session-2/

 

 

Re: error in sending mail

I also checked mail option present in wfa configuration.

There i have given my smtpserver address it worked fine and i got mail to my outlook.

But i dont understand previous error.

 

 

Capture2.JPG

 

 

 

Re: error in sending mail

Try changing this code :

 


        $smtpClient = New-Object System.Net.Mail.SmtpClient
        $mailMessage = New-Object System.Net.Mail.MailMessage

        $smtpClient.host = $SmtpHost
        $mailMessage.To.add($To)
        $mailMessage.from = $From

        $mailMessage.Subject = $Subject
        $mailMessage.Body = "Email from WFA system:`n"

        $smtpClient.Port = 25

        Get-WFALogger -Info -message $("Sending email to " + $To)
        $smtpClient.Send($mailMessage)