Gateway timer script + system.net.sendEmail is giving me SendAsDenied errors

Hi all,

I'm currently working on sending an email through a timer script in the gateway event scripts section. To do this I am using the system.net.sendEmail() function. However, when I attempt to send the email through the SMTP server I've configured I am being presented with the following error:

com.sun.mail.smtp.SMTPSendFailedException: 554 5.2.252 SendAsDenied

From this code:

body = "<HTML><BODY><H1>This is a big header</H1>"
body += "And this text is <font color='red'>red</font></BODY></HTML>"
recipients = ["...@gmail.com"]
title = "Here is the email"
smtp_server = "Test_Email"
system.net.sendEmail(smtpProfile=smtp_server, fromAddr="...@gmail.com", subject="Here is the email!", body=body, html=1, to=recipients)

Note: the emails used in the script are real and used regularly.

I should note that when I use the exact same SMTP server through a pipeline the emails will send as appropriately needed. The issue is I cannot use the pipeline, I need to be able to run these emails through a script. This script does not necessarily need to be in the gateway event scripts either.

Thank you,

Cam

This is the mail server telling you it won't allow you to "send as" whoever you specified in the fromAddr property. For most servers you can't specify any other address than one that matches the credentials you're using to authenticate.

Ohh, That would make sense. For some reason I thought because that email was predefined in the email server settings I didn't think to use it. Thank you :smiley:

I recommend getting a service address from your IT department for each Ignition server with a name that's traceable back to your department. e.g., engineering.ìgnition.gateway.01@mycompany.com`. That way if you ever start flooding the system by accident then IT will know who to contact.

I'll be sure to ask some of the higher IT guys about that. Thank you for the suggestion :smiley:

Do the same with any other devices such as UPS, etc., that email alarms or status reports. Come up with an appropriate naming convention before you start!

Noted :smiley: :+1: