# Ignition email sending fails from script (Gmail STARTTLS 530), but Gateway “Send Test Email” succeeds

**URL:** <https://forum.inductiveautomation.com/t/ignition-email-sending-fails-from-script-gmail-starttls-530-but-gateway-send-test-email-succeeds/110743>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [September 18, 2025, 4:58am UTC](https://forum.inductiveautomation.com/t/ignition-email-sending-fails-from-script-gmail-starttls-530-but-gateway-send-test-email-succeeds/110743 "2025-09-18T04:58:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![xmedmac](https://avatars.discourse-cdn.com/v4/letter/x/96bed5/32.png) [@xmedmac](https://forum.inductiveautomation.com/u/xmedmac)\
**Post date:** [September 18, 2025, 4:58am UTC](https://forum.inductiveautomation.com/t/ignition-email-sending-fails-from-script-gmail-starttls-530-but-gateway-send-test-email-succeeds/110743/1 "2025-09-18T04:58:54Z")

</div>

Hi Ignition Lovers,

I’m seeing inconsistent SMTP behavior in my Ignition environment and would appreciate your help.

## Summary

- **Gateway “Send Test Email”** (Config → Network → Email Settings → my profile) **works**.

- **Sending from a script** (Script Console) **fails** with:

- I need to trigger a Report and email it **asynchronously** from a button.

## Environment

- Ignition Gateway: version 8.1.48 on Windows 11

- SMTP provider: Gmail

- Email Profile name: **A**

- Profile settings currently:

## Steps to Reproduce

1. In Gateway, create/update the Email Profile **A** with the settings above.

2. Click **Send Test Email** → email is delivered successfully.

3. In Designer, run the simplest send (and also from a button):

4. Result: failure with **GatewayException** ; Java cause:

(When I trigger a report and attach its bytes, the same error occurs.)

## What I’ve Tried

- Verified the profile by sending the Gateway test (works).

- Ensured the script calls the same profile name (“A”).

- Confirmed From == Username and I’m using a Gmail App Password.

- Verified basic connectivity to [smtp.gmail.com:587/465](http://smtp.gmail.com:587/465) from the machine.

- Reviewed logs (snippet below).

## Log Snippet

```python
Caused by: com.sun.mail.smtp.SMTPSendFailedException: 530-5.7.0 Must issue a STARTTLS command first. ...
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1300)
...

The error have a poor description of the cause explained for Google here : 
https://support.google.com/a/answer/3726730?hl=es&ref_topic=1355150&sjid=8121797102622003986-NA#

```

## Questions

1. Is there any known issue/limitation where **system.net.sendEmail** from **Client/Designer scope** might not honor the STARTTLS/SSL settings of the named Email Profile—even though the Gateway “Send Test Email” does?

2. Is there a recommended way to guarantee the email is sent in Gateway scope using the same profile (e.g., via `system.util.sendRequest` to a Gateway Message Handler) to avoid scope-related differences?

3. Any additional logging flags for JavaMail in Ignition to confirm the STARTTLS handshake when called from scripts?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [September 18, 2025, 12:30pm UTC](https://forum.inductiveautomation.com/t/ignition-email-sending-fails-from-script-gmail-starttls-530-but-gateway-send-test-email-succeeds/110743/2 "2025-09-18T12:30:27Z")

</div>

> [@xmedmac](#):
>
> In Designer, run the simplest send (and also from a button):
> 
> ```python
> system.net.sendEmail(
> smtp = "smtp.gmail.com", # exact SMTP
> fromAddr = "xmedxxxc97@gmail.com", # same as profile username
> to = ["xmedxxxc@gmail.com"], # Another GMAIL account as destinatary
> subject = "SMTP test",         
> body = "Hi, the email is here"
> )
> 
> ```

You have to use the `smtpProfile` parameter of `sendEmail` and point it at your configured profile by name. By specifying the `smtp` address like that you're just ignoring the profile all together.

> **[system.net.sendEmail | Ignition User Manual](https://docs.inductiveautomation.com/docs/8.3/appendix/scripting-functions/system-net/system-net-sendEmail)**
>
> Sends an email through the given SMTP server.

---

<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:** [September 18, 2025, 12:35pm UTC](https://forum.inductiveautomation.com/t/ignition-email-sending-fails-from-script-gmail-starttls-530-but-gateway-send-test-email-succeeds/110743/3 "2025-09-18T12:35:55Z")

</div>

Relevant:

> [@What email address goes in "From Address" field for email notifications?](https://forum.inductiveautomation.com/t/what-email-address-goes-in-from-address-field-for-email-notifications/110434/4):
>
> Don't! Make sure that the emails themselves contain a "from" address that will lead back to the relevant server and script in the event that a malfunction (such as rapidly-repeating emails) causes mail problems. Failure to sort out flooding issues may result in loss or closure of your email system and could be costly for your business. I usually use something like \<scriptname\>.\<servername\>.\<plant\>.\<country\>@\<company-name\>.\<tld\> It will also make it look like someone competent and organised i…

---

<div class="post-metadata">

**Author:** ![xmedmac](https://avatars.discourse-cdn.com/v4/letter/x/96bed5/32.png) [@xmedmac](https://forum.inductiveautomation.com/u/xmedmac)\
**Post date:** [September 18, 2025, 5:02pm UTC](https://forum.inductiveautomation.com/t/ignition-email-sending-fails-from-script-gmail-starttls-530-but-gateway-send-test-email-succeeds/110743/4 "2025-09-18T17:02:26Z")

</div>

Thanks, Kevin

that was the missing piece. I created an SMTP profile in the Gateway ([smtp.gmail.com:587](http://smtp.gmail.com:587) with STARTTLS and a Gmail app password) and then called `system.net.sendEmail` using the `smtpProfile` parameter:

system.net.sendEmail(  
smtpProfile="GmailProfile",  
fromAddr = "my gmail account”,  
to=["gmail destiny accounts"],  
subject="SMTP test",  
body="It works!"  
)

The test mail went through immediately. I was mistakenly passing the `smtp` host in the script and ignoring the profile. After switching to `smtpProfile`, everything works as expected. Appreciate the pointer and the docs link!
