# Issue sending email in script

**URL:** <https://forum.inductiveautomation.com/t/issue-sending-email-in-script/90406>\
**Category:** Ignition\
**Tags:** scripting, ignition81, perspective\
**Created:** [May 15, 2024, 8:01am UTC](https://forum.inductiveautomation.com/t/issue-sending-email-in-script/90406 "2024-05-15T08:01:11Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [May 15, 2024, 8:28am UTC](https://forum.inductiveautomation.com/t/issue-sending-email-in-script/90406/2 "2024-05-15T08:28:20Z")

</div>

1. I can't see a definite problem but from the manual I see,

> `smtpProfile`  
> If specified, the named SMTP profile defined in the Gateway will be used. If this keyword is present, the smtp, username, and password keywords will be ignored. [optional]

So you can drop the `smtp = smtp1` from sendEmail. Part of the idea here is that you would not hard-code the settings in your script but just point to the SMTP profile. Then if you ever change from [Outlook.com](http://Outlook.com) you just have to edit that gateway's SMTP server setting and all scripts will continue to work.

1. Does smtp2 exactly match the name of the profile?

2. I recommend that you set the from address to something like `scriptname.projectname@servername.companyname.com` and construct this programmatically so that it auto-updates if the project is copied or moved to another server. It will be a big help in debugging quickly if the script goes rogue and your company's email gets blacklisted!

3. Tip: post code - not pictures of code - unless context is important in which case you can post both. See [Wiki - how to post code on this forum](https://forum.inductiveautomation.com/t/wiki-how-to-post-code-on-this-forum/77831).

---

_[View the full topic](https://forum.inductiveautomation.com/t/issue-sending-email-in-script/90406)._
