# SMTP Fails in Perspective

**URL:** <https://forum.inductiveautomation.com/t/smtp-fails-in-perspective/35773>\
**Category:** Ignition\
**Created:** [June 17, 2020, 7:59pm UTC](https://forum.inductiveautomation.com/t/smtp-fails-in-perspective/35773 "2020-06-17T19:59:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kyle.lawson](https://avatars.discourse-cdn.com/v4/letter/k/6de8d8/32.png) [@kyle.lawson](https://forum.inductiveautomation.com/u/kyle.lawson)\
**Post date:** [June 17, 2020, 7:59pm UTC](https://forum.inductiveautomation.com/t/smtp-fails-in-perspective/35773/1 "2020-06-17T19:59:18Z")

</div>

Hello,

In vision I use the code below to send an email based on a script. When I try it in perspective I get an error that connection is refused. What in perspective would be causing this? The code is identical in both vision and perspective. Works in vision but not perspective.

import smtplib

recepients = [“XXXX@XXXX”]

server = smtplib.SMTP(‘XXXXXXX’,25)  
server.login(“XXXXXXXXXXXXXX”, “XXXXXXX”)  
msg = “”“TESTING  
\n\nThis is a test.  
“””  
server.sendmail(  
“XXXXXXXXXX”,  
recepients,  
msg  
)  
server.quit()

---

<div class="post-metadata">

**Author:** ![code\_skin](https://avatars.discourse-cdn.com/v4/letter/c/43a26b/32.png) [@code\_skin](https://forum.inductiveautomation.com/u/code_skin)\
**Post date:** [June 17, 2020, 8:04pm UTC](https://forum.inductiveautomation.com/t/smtp-fails-in-perspective/35773/2 "2020-06-17T20:04:16Z")

</div>

I’m not sure what the difference would be but perhaps client vs gateway scope.  
I will suggest looking into system.net.sendEmail() to see if that resolves your issue.

---

<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:** [June 17, 2020, 8:04pm UTC](https://forum.inductiveautomation.com/t/smtp-fails-in-perspective/35773/3 "2020-06-17T20:04:20Z")

</div>

Where were you running it in Vision? Perspective code is always executed on the gateway.

---

<div class="post-metadata">

**Author:** ![kyle.lawson](https://avatars.discourse-cdn.com/v4/letter/k/6de8d8/32.png) [@kyle.lawson](https://forum.inductiveautomation.com/u/kyle.lawson)\
**Post date:** [June 18, 2020, 11:37am UTC](https://forum.inductiveautomation.com/t/smtp-fails-in-perspective/35773/4 "2020-06-18T11:37:22Z")

</div>

I was running the designer on my business network pc but the gateway is on the industrial side. So it was working when running vision on the business network pc. Once I tried it on the industrial side, neither the vision or perspective code works. Thanks, for making that clear to me now.
