Solved

Issues sending emails from script

Posted on 2016-07-26
5
37 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 68

Accepted Solution

by:
Qlemo earned 250 total points
Comment Utility
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
Comment Utility
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
Comment Utility
Steven,


Qlemo thread should be the asnwer.
0
 
LVL 7

Expert Comment

by:Senior IT System Engineer
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

We are happy to announce a brand new addition to our line of acclaimed email signature management products – CodeTwo Email Signatures for Office 365.
Disabling the Directory Sync Service Account in Office 365 will stop directory synchronization from working.
To show how to generate a certificate request in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.:  First we need to log into the Exchange Admin Center. Navigate to the Servers >> Certificates…
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

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now