Solved

Issues sending emails from script

Posted on 2016-07-26
5
45 Views
1 Endorsement
Last Modified: 2016-07-31
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
1
Comment
Question by:Steven Reid
  • 2
5 Comments
 
LVL 69

Accepted Solution

by:
Qlemo earned 250 total points
ID: 41729249
Exchange is not part of the equation. The script uses SMTP to send a mail message, and the Send() method can fail because of a lot of reasons. Check that the corresponding variables at the script head are set correctly, including password.
2
 

Author Comment

by:Steven Reid
ID: 41736834
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
1
 
LVL 7

Assisted Solution

by:Senior IT System Engineer
Senior IT System Engineer earned 250 total points
ID: 41736838
Steven,


Qlemo thread should be the asnwer.
0
 
LVL 7

Expert Comment

by:Senior IT System Engineer
ID: 41736862
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

1

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lotus Notes – formerly IBM Notes – is an email client application, while IBM Domino (earlier Lotus Domino) is an email server. The client possesses a set of features that are even more advanced as compared to that of Outlook. Likewise, IBM Domino is…
Local Continuous Replication is a cost effective and quick way of backing up Exchange server data. The following article describes the steps required to configure Local Continuous Replication. Also, the article tells you how to restore from a backup…
The video tutorial explains the basics of the Exchange server Database Availability groups. The components of this video include: 1. Automatic Failover 2. Failover Clustering 3. Active Manager
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question