Link to home
Start Free TrialLog in
Avatar of Steven Reid
Steven ReidFlag for Australia

asked on

Issues sending emails from script

I had this question after viewing Notify AD users by sending email to them before their password gets expired.

I have used the script above to create a reminder email to send out to users.

the trouble is that i keep getting errors when sending the email, saying error message like below

Error Sending Email to xxxx using the email xxxxx Failed item is . The error message was Exception calling "Send" with "1" argument(s): "Failure sending mail."

I am trying to run the powershell script on the exchange server itself, so am not sure what the issue is.

any ideas?
Password_Change_Notification.txt
ASKER CERTIFIED SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Steven Reid

ASKER

For others information, turned out to be the fact that the saved password that was being used was generated under one user account, but I was using a different user account to read that password.  so was not being decrypted properly.

When i ran it under the same account, it was all good.

Thanks
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Here's the PowerShell script for your testing in case you need it:

Send-MailMessage -From "Sender@PowerShell.domain.com" -To "yourself@domain.com" -Subject "Testing email relay" -Body "Anonymous Email Relay" -SmtpServer "SMTP.domain.com" -DeliveryNotificationOption OnFailure -Verbose

Open in new window