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

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:

    com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.0 Must issue a STARTTLS command first
    
  • 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:

    • Host: smtp.gmail.com

    • Port: 587

    • Use STARTTLS: enabled

    • Use SSL/TLS port: disabled

    • Require authentication: enabled

    • Username / From: xmedxxxc97@gmail.com

    • Password: Google App Password

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):

    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"
    )
    
  4. Result: failure with GatewayException; Java cause:

    com.sun.mail.smtp.SMTPSendFailedException: 530-5.7.0 Must issue a STARTTLS command first
    
    

(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 from the machine.

  • Reviewed logs (snippet below).

Log Snippet

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?

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.

Relevant:

Thanks, Kevin

that was the missing piece. I created an SMTP profile in the Gateway (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!