# SMTP server email is not working in the script

**URL:** <https://forum.inductiveautomation.com/t/smtp-server-email-is-not-working-in-the-script/91722>\
**Category:** Ignition\
**Tags:** perspective, ignition81\
**Created:** [June 12, 2024, 6:15am UTC](https://forum.inductiveautomation.com/t/smtp-server-email-is-not-working-in-the-script/91722 "2024-06-12T06:15:04Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![srinivasan\_s](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@srinivasan\_s](https://forum.inductiveautomation.com/u/srinivasan_s)\
**Post date:** [June 12, 2024, 6:15am UTC](https://forum.inductiveautomation.com/t/smtp-server-email-is-not-working-in-the-script/91722/1 "2024-06-12T06:15:04Z")

</div>

I have successfully configured the SMTP Gmail server in ignition. I have tested it too, able to send email from the ignition test option. When I try to use system.net.sendEmail in my script, not able to send email. Here is my code,

```python
smtp = "smtp.gmail.com:587"
		myFrom = "srinisekar9899@gmail.com"
		subject = "Here is the email!"
		body = "New Ticket has been created"
		html = 0
		recipients = ["seenudhanum283@gmail.com"]
		system.net.sendEmail(smtp,myFrom, subject, body, html, recipients)

```

Attached the image of SMTP server setting.

 ![smtp](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/f/cf730aa852a2e12dcfe32802656293f323387a21.png)

Kindly help me out. I am using ignition in AWS server .

Adding the error message!

" Error running action 'dom.onClick' on Templates/Ticketing/createTicketPopUp@PaddNewTicket/root/DownloadFlex/Button: Traceback (most recent call last): File "function:runAction", line 23, in runAction 530-5.7.0 [About SMTP error messages - Google Workspace Admin Help](https://support.google.com/a/answer/3221692) and review RFC 3207 530 5.7.0 specifications. d2e1a72fcca58-7042eba77e2sm6137676b3a.104 - gsmtp at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:2358) at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:1823) at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1300) at javax.mail.Transport.send0(Transport.java:255) at javax.mail.Transport.send(Transport.java:124) at com.inductiveautomation.ignition.gateway.script.GatewayNetUtilities.sendEmail(GatewayNetUtilities.java:262) at com.inductiveautomation.ignition.gateway.script.GatewayNetUtilities.sendEmail(GatewayNetUtilities.java:133) at com.inductiveautomation.ignition.gateway.script.GatewayNetUtilities.\_sendEmail(GatewayNetUtilities.java:59) at com.inductiveautomation.ignition.common.script.builtin.AbstractNetUtilities.sendEmail(AbstractNetUtilities.java:161) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) com.sun.mail.smtp.SMTPSendFailedException: com.sun.mail.smtp.SMTPSendFailedException: 530-5.7.0 Must issue a STARTTLS command first. For more information, go to 530-5.7.0 [About SMTP error messages - Google Workspace Admin Help](https://support.google.com/a/answer/3221692) and review RFC 3207 530 5.7.0 specifications. d2e1a72fcca58-7042eba77e2sm6137676b3a.104 - gsmtp"

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [June 12, 2024, 10:41am UTC](https://forum.inductiveautomation.com/t/smtp-server-email-is-not-working-in-the-script/91722/2 "2024-06-12T10:41:34Z")

</div>

Use the `smtpProfile` argument to [system.net.sendEmail()](https://www.docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-net/system-net-sendEmail) instead of the `smtp` argument. When you use `smtp`, the function bypasses the profile you tested.

---

<div class="post-metadata">

**Author:** ![srinivasan\_s](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@srinivasan\_s](https://forum.inductiveautomation.com/u/srinivasan_s)\
**Post date:** [June 12, 2024, 11:21am UTC](https://forum.inductiveautomation.com/t/smtp-server-email-is-not-working-in-the-script/91722/3 "2024-06-12T11:21:02Z")

</div>

Thank you for reply. I tried the same , but same issue, not able to send the mail.

```python
# smtpProfile = "smtp.gmail.com:587"
# myFrom = "srinisekar9899@gmail.com"
# subject = "Here is the email!"
# body = "New Ticket has been created"
# html = 0
# recipients = ["srinisekar9899@gmail.com"]
# system.net.sendEmail(smtpProfile,myFrom, subject, body, html, recipients)
## # Closes a docked view with the given dock id.

```

---

<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:** [June 12, 2024, 11:57am UTC](https://forum.inductiveautomation.com/t/smtp-server-email-is-not-working-in-the-script/91722/4 "2024-06-12T11:57:12Z")

</div>

> [@srinivasan\_s](#):
>
> but same issue

You've commented out all your code. What are you actually running?

Tip: set the "from" to something like `scriptname.projectname@gatewayname.mycompany.com` so that if it starts to go mad you or your IT department will be able to find the source of the problem.

Are you posting your real email address on a public forum?

---

<div class="post-metadata">

**Author:** ![amy.sudibyo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amy.sudibyo/32/38659_2.png) [@amy.sudibyo](https://forum.inductiveautomation.com/u/amy.sudibyo)\
**Post date:** [June 12, 2024, 11:41pm UTC](https://forum.inductiveautomation.com/t/smtp-server-email-is-not-working-in-the-script/91722/5 "2024-06-12T23:41:39Z")

</div>

All you have done here is rename your input variable from `smtp` to `smtpProfile`. You are still passing in an `smtp` parameter to `system.net.sendEmail()`.

What is the name of the SMTP profile you have configured in your gateway? You need to pass this name into the function into the `smtpProfile` parameter

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/8/c81ac614f27f32344cbbf00662d61e8f74070013.png)

---

<div class="post-metadata">

**Author:** ![srinivasan\_s](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@srinivasan\_s](https://forum.inductiveautomation.com/u/srinivasan_s)\
**Post date:** [June 13, 2024, 4:34am UTC](https://forum.inductiveautomation.com/t/smtp-server-email-is-not-working-in-the-script/91722/6 "2024-06-13T04:34:00Z")

</div>

thank you for your reply. I have uncommented the code only then i have run the code. But facing same issue.  
tip.... 😄

---

<div class="post-metadata">

**Author:** ![srinivasan\_s](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@srinivasan\_s](https://forum.inductiveautomation.com/u/srinivasan_s)\
**Post date:** [June 13, 2024, 4:34am UTC](https://forum.inductiveautomation.com/t/smtp-server-email-is-not-working-in-the-script/91722/7 "2024-06-13T04:34:42Z")

</div>

Thank you for your reply. I will try now and get back to you

---

<div class="post-metadata">

**Author:** ![srinivasan\_s](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@srinivasan\_s](https://forum.inductiveautomation.com/u/srinivasan_s)\
**Post date:** [June 13, 2024, 5:04am UTC](https://forum.inductiveautomation.com/t/smtp-server-email-is-not-working-in-the-script/91722/8 "2024-06-13T05:04:20Z")

</div>

Hi ! I tried the below code, still not able to send email. Kindly help me with your input.

```python
smtp = "smtp.gmail.com:587"
		smtpProf = "TicketEmailServer"
		myFrom = "srinisekar9899@gmail.com"
		subject = "Here is the email!"
		body = "New Ticket has been created"
		html = 0
		myuser = "srinisekar9899@gmail.com"
		mypass = "zgeb unjz orow hseh"
		recipients = ["srinisekar9899@gmail.com"]
		system.net.sendEmail(smtp,myFrom, subject, body, html, recipients,username=myuser, password=mypass, smtpProfile=smtpProf)

```

---

<div class="post-metadata">

**Author:** ![amy.sudibyo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amy.sudibyo/32/38659_2.png) [@amy.sudibyo](https://forum.inductiveautomation.com/u/amy.sudibyo)\
**Post date:** [June 13, 2024, 5:45am UTC](https://forum.inductiveautomation.com/t/smtp-server-email-is-not-working-in-the-script/91722/9 "2024-06-13T05:45:57Z")

</div>

As per my last screenshot, if you are supplying an SMTP profile argument the function will ignore smtp, username and password inputs so you don't need to supply these (nor should you be sharing your password on a public forum...)

You have supplied the optional html parameter with a 0, when it is a Boolean, so it should be `False`.

---

<div class="post-metadata">

**Author:** ![srinivasan\_s](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@srinivasan\_s](https://forum.inductiveautomation.com/u/srinivasan_s)\
**Post date:** [June 13, 2024, 5:52am UTC](https://forum.inductiveautomation.com/t/smtp-server-email-is-not-working-in-the-script/91722/10 "2024-06-13T05:52:39Z")

</div>

thank you. Will check.  
All these email, password are fake ones. 😊

---

<div class="post-metadata">

**Author:** ![srinivasan\_s](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@srinivasan\_s](https://forum.inductiveautomation.com/u/srinivasan_s)\
**Post date:** [June 13, 2024, 12:53pm UTC](https://forum.inductiveautomation.com/t/smtp-server-email-is-not-working-in-the-script/91722/11 "2024-06-13T12:53:59Z")

</div>

I tired the say, but same not working,

```python
            myFrom = "srinisekar9899@gmail.com"
			subject = "Here is the email!"
			body = "New Ticket has been created"
			html = False
# myuser = "srinisekar9899@gmail.com"
# mypass = "zgeb unjz orow hseh"
			recipients = ["srinisekar9899@gmail.com"]
			system.net.sendEmail(myFrom, subject, body, html, recipients,smtpProfile=smtpProf)

```

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [June 13, 2024, 2:29pm UTC](https://forum.inductiveautomation.com/t/smtp-server-email-is-not-working-in-the-script/91722/12 "2024-06-13T14:29:22Z")

</div>

Can you post your entire code block? I think you are still missing something.

Also, have you tested the SMTP Profile to verify that it will send e-mails?

---

<div class="post-metadata">

**Author:** ![Bushmatic](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bushmatic/32/87014_2.png) [@Bushmatic](https://forum.inductiveautomation.com/u/Bushmatic)\
**Post date:** [June 13, 2024, 3:20pm UTC](https://forum.inductiveautomation.com/t/smtp-server-email-is-not-working-in-the-script/91722/13 "2024-06-13T15:20:15Z")

</div>

You might try supplying keyword arguments to the whole function instead of just the smtp profile argument. There are a lot of arguments this function can take:

`system.net. sendEmail( smtp, fromAddr, [subject] , [body] , [html] , to, [attachmentNames] , [attachmentData] , [timeout] , [username] , [password] , [priority] , [smtpProfile] , [cc] , [bcc] , [retries], [replyTo] )`

So instead of:  
`system.net.sendEmail(myFrom, subject, body, html, recipients,smtpProfile=smtpProf)`

Try:  
`system.net.sendEmail(fromAddr=myFrom,subject=subject,body=body,html=html,to=recipients,smtpProfile=smtpProf)`

Maybe even strip it down to just the required arguments and build it back up from there:  
`system.net.sendEmail(fromAddr=myFrom,to=recipients,smtpProfile=smtpProf)`

This is assuming your `smtpProf` variable is a string with the same name as the one you defined in your gateway configuration (screenshot below). It looks like you are missing a line of code where you define this variable, unless you just didn't copy it here. If that is indeed your whole code, I think you are supplying that argument incorrectly.

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/a/3a152d5473009b9ca96dcb23a67b27286bceb037.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/5/c5fbfe79f67df7a5aeb1a3fb1683d4c007756985.png)

---

<div class="post-metadata">

**Author:** ![srinivasan\_s](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@srinivasan\_s](https://forum.inductiveautomation.com/u/srinivasan_s)\
**Post date:** [June 14, 2024, 11:17am UTC](https://forum.inductiveautomation.com/t/smtp-server-email-is-not-working-in-the-script/91722/14 "2024-06-14T11:17:59Z")

</div>

Thank you for your reply. Here is my revised code. Still not able to receive the mail. Kindly check .

```python
        smtpProf = "TicketEmailServer"
		myFrom = "srinisekar9899@gmail.com"
		subject = "Here is the email!"
		body = "New Ticket has been created"
		html = False
# myuser = "srinisekar9899@gmail.com"
# mypass = "zgeb unjz orow hseh"
		recipients = ["srinisekar9899@gmail.com"]
		system.net.sendEmail(fromAddr=myFrom,subject=subject,body=body,html=html,to=recipients,smtpProfile=smtpProf)

```

 ![test](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/f/5f942709fe4e685f764786f4d244eaa1a2ff4af3.png)

---

<div class="post-metadata">

**Author:** ![srinivasan\_s](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@srinivasan\_s](https://forum.inductiveautomation.com/u/srinivasan_s)\
**Post date:** [June 14, 2024, 11:21am UTC](https://forum.inductiveautomation.com/t/smtp-server-email-is-not-working-in-the-script/91722/15 "2024-06-14T11:21:02Z")

</div>

Thank you for your reply. Actually just I am trying to collect the data in the text field areas in my form to update in the DB.

```python
#	self.parent.parent.getChild("testing").props.text = "deviceName"
	ticketID = system.db.runNamedQuery("Tickets/get_LastTicketID").getValueAt(0, 0)
	deviceName = self.parent.parent.getChild("Site_SysFlexRepeater").props.instances[0].value
	siteID = self.parent.parent.getChild("Site_SysFlexRepeater").props.instances[1].value
	ticketCategory = self.parent.parent.getChild("Reason_UserFlexRepeater_0").props.instances[0].options[0].value
	ticketDescription = self.parent.parent.getChild("FlexContainer").getChild("TextArea").props.text
	ticketStatus = "OPEN"
	userid = self.parent.parent.getChild("Reason_UserFlexRepeater_0").props.instances[1].options[0].value
#	system.db.runNamedQuery("Tickets/insert_TicketMaster", {"inVarTicketID": ticketID , "inVarTicketStatus": ticketStatus})
#	system.db.runNamedQuery("Tickets/insert_Ticket", {"inVarTicketID":ticketID, "inVarDeviceName": deviceName, "inVarSiteID": siteID, "inVarTicketCategory": ticketCategory, "inVarTicketDescription": ticketDescription, "inVarTicketStatus": ticketStatus, "inVarUserID": userid})

	if deviceName != '' and siteID != '' and ticketCategory != '' and ticketDescription != '':
		system.db.runNamedQuery("Tickets/insert_TicketMaster", {"inVarTicketID": ticketID , "inVarTicketStatus": ticketStatus})
		system.db.runNamedQuery("Tickets/insert_Ticket", {"inVarTicketID":ticketID, "inVarDeviceName": deviceName, "inVarSiteID": siteID, "inVarTicketCategory": ticketCategory, "inVarTicketDescription": ticketDescription, "inVarTicketStatus": ticketStatus, "inVarUserID": userid})
		system.perspective.sendMessage('refresh',scope = 'page')
# smtp = "smtp.gmail.com:587"
		smtpProf = "TicketEmailServer"
		myFrom = "srinisekar9899@gmail.com"
		subject = "Here is the email!"
		body = "New Ticket has been created"
		html = False
# myuser = "srinisekar9899@gmail.com"
# mypass = "zgeb unjz orow hseh"
		recipients = ["srinisekar9899@gmail.com"]
		system.net.sendEmail(fromAddr=myFrom,subject=subject,body=body,html=html,to=recipients,smtpProfile=smtpProf)
## # Closes a docked view with the given dock id.
		system.perspective.closePopup('addNewTicket')
		try:
# smtpProf = "TicketEmailServer"
			myFrom = "srinisekar9899@gmail.com"
			subject = "Here is the email!"
			body = "New Ticket has been created"
			html = False
# myuser = "srinisekar9899@gmail.com"
# mypass = "zgeb unjz orow hseh"
			recipients = ["srinisekar9899@gmail.com"]
			system.net.sendEmail(myFrom, subject, body, html, recipients,smtpProfile=smtpProf)
		except:
			pass
		
	else:
		system.perspective.openPopup('errorMessage','Templates/General/messageBox',params = {'Text':'Enter all the fields!'},modal=True,showCloseIcon=False,viewportBound=True)

```

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [June 14, 2024, 12:14pm UTC](https://forum.inductiveautomation.com/t/smtp-server-email-is-not-working-in-the-script/91722/16 "2024-06-14T12:14:58Z")

</div>

Do you know that the e-mail profile works?

You can test it via the web page at Config-\>Networking-\>EMail Settings, and then under "More" on the e-mail profile click test.  
Once you have that working, then you take the next step to getting the code working.

---

<div class="post-metadata">

**Author:** ![srinivasan\_s](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@srinivasan\_s](https://forum.inductiveautomation.com/u/srinivasan_s)\
**Post date:** [June 17, 2024, 11:24am UTC](https://forum.inductiveautomation.com/t/smtp-server-email-is-not-working-in-the-script/91722/17 "2024-06-17T11:24:02Z")

</div>

Thank you bschroder, that has successful message, but still not working

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [June 17, 2024, 11:30am UTC](https://forum.inductiveautomation.com/t/smtp-server-email-is-not-working-in-the-script/91722/18 "2024-06-17T11:30:59Z")

</div>

Hmmm... Are you sure you are getting to the line to send the email?

Maybe stick some logging in your logic after the if, and right before the send function just to verify that you are getting to that point.

And absolutely no errors at all when you run this code? Make sure to check both the client and designer.

---

<div class="post-metadata">

**Author:** ![OmarTentmaker](https://avatars.discourse-cdn.com/v4/letter/o/9fc348/32.png) [@OmarTentmaker](https://forum.inductiveautomation.com/u/OmarTentmaker)\
**Post date:** [September 4, 2025, 5:15pm UTC](https://forum.inductiveautomation.com/t/smtp-server-email-is-not-working-in-the-script/91722/19 "2025-09-04T17:15:39Z")

</div>

smtpProfile=smtpProf was the solution for me!

First, I logged into the Gateway and created my "Classic\_SMTP\_Profile\_OmarTentmaker" Email Profile (Config \> Network \> Email Profiles):

 ![Classic_SMTP_Profile_Omar_Morgan](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/4/e48ffbebe5d327877831b5e09db2ac40e9a7db62.jpeg)

Then, I was able to change my code

from

> **Summary**
>
> ```python
> SMTPtext = "smtp.abcd.mycompanyname.com"
> system.net.sendEmail(smtp=SMTPtext, fromAddr=fromADDRtext, subject=SUBJECTtext, body=BODYtext, html=HTMLboolean, to=toADDRtext, cc=ccADDRtext)
> 
> ```

to

> **Summary**
>
> ```python
> smtpProf = "Classic_SMTP_Profile_OmarTentmaker"
> system.net.sendEmail(smtpProfile=smtpProf, fromAddr=fromADDRtext, subject=SUBJECTtext, body=BODYtext, html=HTMLboolean, to=toADDRtext, cc=ccADDRtext)	
> 
> ```

I am getting emails now with BOTH the To and the Cc lines populated. Thank you!!
