# SMTPSecureSocket

**URL:** <https://forum.xojo.com/t/smtpsecuresocket/21298>\
**Category:** Getting Started\
**Created:** [December 30, 2014, 7:01pm UTC](https://forum.xojo.com/t/smtpsecuresocket/21298 "2014-12-30T19:01:12Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexis\_Colon\_Lugo](https://forum.xojo.com/user_avatar/forum.xojo.com/alexis_colon_lugo/32/572_2.png) [@Alexis\_Colon\_Lugo](https://forum.xojo.com/u/Alexis_Colon_Lugo)\
**Post date:** [December 30, 2014, 7:01pm UTC](https://forum.xojo.com/t/smtpsecuresocket/21298/1 "2014-12-30T19:01:12Z")

</div>

how i can get the error msg ( i have a error but no from server)  
SMTPSecureSocket.error \<\<

---

<div class="post-metadata">

**Author:** ![Alexis\_Colon\_Lugo](https://forum.xojo.com/user_avatar/forum.xojo.com/alexis_colon_lugo/32/572_2.png) [@Alexis\_Colon\_Lugo](https://forum.xojo.com/u/Alexis_Colon_Lugo)\
**Post date:** [December 30, 2014, 8:22pm UTC](https://forum.xojo.com/t/smtpsecuresocket/21298/2 "2014-12-30T20:22:18Z")

</div>

my code (the Error code is 102)

```
eMailServer.Address ="smtp.myhost.com"
eMailServer.Secure = True
eMailServer.SMTPConnectionMode=0

eMailServer.ConnectionType=SSLSocket.TLSv1
eMailServer.Port = 587
eMailServer.Username ="acolon@myhost.com"
eMailServer.Password ="test101"
eMailServer.Connect()

```

this is correct or no

---

<div class="post-metadata">

**Author:** ![Tim\_Hare](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_hare/32/176_2.png) [@Tim\_Hare](https://forum.xojo.com/u/Tim_Hare)\
**Post date:** [December 30, 2014, 8:56pm UTC](https://forum.xojo.com/t/smtpsecuresocket/21298/3 "2014-12-30T20:56:45Z")

</div>

No. You do not call Connect on an SMTP socket. Just SendMail. The connection is handled behind the scenes. SendMail connects, transmits, and disconnects. You do not keep a connection to the server.

---

<div class="post-metadata">

**Author:** ![Bob\_Keeney](https://forum.xojo.com/letter_avatar_proxy/v4/letter/b/54ee81/32.png) [@Bob\_Keeney](https://forum.xojo.com/u/Bob_Keeney)\
**Post date:** [December 30, 2014, 9:50pm UTC](https://forum.xojo.com/t/smtpsecuresocket/21298/4 "2014-12-30T21:50:42Z")

</div>

And error 102 is really not an error. It just means the connection has dropped. SMTPSockets will do that quite a bit.

---

<div class="post-metadata">

**Author:** ![Alexis\_Colon\_Lugo](https://forum.xojo.com/user_avatar/forum.xojo.com/alexis_colon_lugo/32/572_2.png) [@Alexis\_Colon\_Lugo](https://forum.xojo.com/u/Alexis_Colon_Lugo)\
**Post date:** [December 30, 2014, 11:53pm UTC](https://forum.xojo.com/t/smtpsecuresocket/21298/5 "2014-12-30T23:53:37Z")

</div>

but the email no get to any place.  
i remove the eMailServer.Connect()

---

<div class="post-metadata">

**Author:** ![Bob\_Keeney](https://forum.xojo.com/letter_avatar_proxy/v4/letter/b/54ee81/32.png) [@Bob\_Keeney](https://forum.xojo.com/u/Bob_Keeney)\
**Post date:** [December 31, 2014, 12:21am UTC](https://forum.xojo.com/t/smtpsecuresocket/21298/6 "2014-12-31T00:21:20Z")

</div>

First you create the email message [http://documentation.xojo.com/index.php/EmailMessage](http://documentation.xojo.com/index.php/EmailMessage)

Then you append that email to the socket. [http://documentation.xojo.com/index.php/SMTPSecureSocket.Messages](http://documentation.xojo.com/index.php/SMTPSecureSocket.Messages)

Then you call SendMail. [http://documentation.xojo.com/index.php/SMTPSecureSocket.SendMail](http://documentation.xojo.com/index.php/SMTPSecureSocket.SendMail)

You do NOT have to call Connect. The socket connects and disconnects for you automatically.

---

<div class="post-metadata">

**Author:** ![Norman\_P](https://forum.xojo.com/letter_avatar_proxy/v4/letter/n/858c86/32.png) [@Norman\_P](https://forum.xojo.com/u/Norman_P)\
**Post date:** [December 31, 2014, 12:53am UTC](https://forum.xojo.com/t/smtpsecuresocket/21298/7 "2014-12-31T00:53:12Z")

</div>

and make sure you keep the socket around long enough so it doesnt go out of scope immediately  
it will never send if you dont

---

<div class="post-metadata">

**Author:** ![Richard\_Duke](https://forum.xojo.com/user_avatar/forum.xojo.com/richard_duke/32/246_2.png) [@Richard\_Duke](https://forum.xojo.com/u/Richard_Duke)\
**Post date:** [October 14, 2019, 11:43pm UTC](https://forum.xojo.com/t/smtpsecuresocket/21298/8 "2019-10-14T23:43:33Z")

</div>

[quote=156182:@Norman Palardy]and make sure you keep the socket around long enough so it doesnt go out of scope immediately  
it will never send if you dont[/quote]

how do i keep the socket around long enough??

---

<div class="post-metadata">

**Author:** ![Rick\_Araujo](https://forum.xojo.com/user_avatar/forum.xojo.com/rick_araujo/32/251_2.png) [@Rick\_Araujo](https://forum.xojo.com/u/Rick_Araujo)\
**Post date:** [October 14, 2019, 11:58pm UTC](https://forum.xojo.com/t/smtpsecuresocket/21298/9 "2019-10-14T23:58:42Z")

</div>

> [@458312:@Richard Duke](#):
>
> how do i keep the socket around long enough??

Instantiate it in a scope that lives the intended time. For example, a property in the window showing a progress bar of the sending job. It will die only when the window gets closed and all the window properties got released/destructed.

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 5:33pm UTC](https://forum.xojo.com/t/smtpsecuresocket/21298/10 "2020-10-29T17:33:19Z")

</div>


