Solved

Issues sending emails from script

Posted on 2016-07-26
5
54 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 70

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 8

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 8

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This video discusses moving either the default database or any database to a new volume.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the adminiā€¦

691 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