# \[Help\]How to connect to a smtp server?

**URL:** <https://forums.unrealengine.com/t/help-how-to-connect-to-a-smtp-server/393627>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [May 15, 2017, 6:44am UTC](https://forums.unrealengine.com/t/help-how-to-connect-to-a-smtp-server/393627 "2017-05-15T06:44:38Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![LuooYu](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@LuooYu](https://forums.unrealengine.com/u/LuooYu)\
**Post date:** [May 15, 2017, 6:44am UTC](https://forums.unrealengine.com/t/help-how-to-connect-to-a-smtp-server/393627/1 "2017-05-15T06:44:38Z")

</div>

I use the FSocket link to the specified SMTP server, but I found that when the server sends an ACK request when the FSocket did not respond.  
Is this an FSocket defect? Or is it because my setup has a problem?

---

<div class="post-metadata">

**Author:** ![6r0m](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/6r0m/32/1194563_2.png) [@6r0m](https://forums.unrealengine.com/u/6r0m)\
**Post date:** [August 21, 2019, 9:39am UTC](https://forums.unrealengine.com/t/help-how-to-connect-to-a-smtp-server/393627/2 "2019-08-21T09:39:24Z")

</div>

did you solve this and can you share your code?

---

<div class="post-metadata">

**Author:** ![LuooYu](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@LuooYu](https://forums.unrealengine.com/u/LuooYu)\
**Post date:** [August 23, 2019, 6:46am UTC](https://forums.unrealengine.com/t/help-how-to-connect-to-a-smtp-server/393627/3 "2019-08-23T06:46:54Z")

</div>

Yes, i solved it. Use the libcurl in the engine thridparty folder.

```
    AddEngineThirdPartyPrivateStaticDependencies(Target, "libcurl");
    AddEngineThirdPartyPrivateStaticDependencies(Target, "OpenSSL");
```

---

<div class="post-metadata">

**Author:** ![6r0m](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/6r0m/32/1194563_2.png) [@6r0m](https://forums.unrealengine.com/u/6r0m)\
**Post date:** [August 23, 2019, 7:00am UTC](https://forums.unrealengine.com/t/help-how-to-connect-to-a-smtp-server/393627/4 "2019-08-23T07:00:17Z")

</div>

Thank you very much! headers can included finally.

and if you can - could you give small example, please.

It’s like this [libcurl example - smtp-mail.c](https://curl.haxx.se/libcurl/c/smtp-mail.html) or there are a lot of nuisances?

---

<div class="post-metadata">

**Author:** ![LuooYu](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@LuooYu](https://forums.unrealengine.com/u/LuooYu)\
**Post date:** [August 24, 2019, 3:05pm UTC](https://forums.unrealengine.com/t/help-how-to-connect-to-a-smtp-server/393627/5 "2019-08-24T15:05:00Z")

</div>

The example on the web site is not good about the part of the header.

My code is here.

---

<div class="post-metadata">

**Author:** ![6r0m](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/6r0m/32/1194563_2.png) [@6r0m](https://forums.unrealengine.com/u/6r0m)\
**Post date:** [August 27, 2019, 1:11pm UTC](https://forums.unrealengine.com/t/help-how-to-connect-to-a-smtp-server/393627/6 "2019-08-27T13:11:32Z")

</div>

hey, thank you.

I’m tried it, but emails arrived empty (without subject, body and etc), may be because my Header .

can you give some advice, please?

link text

---

<div class="post-metadata">

**Author:** ![LuooYu](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@LuooYu](https://forums.unrealengine.com/u/LuooYu)\
**Post date:** [August 27, 2019, 4:45pm UTC](https://forums.unrealengine.com/t/help-how-to-connect-to-a-smtp-server/393627/7 "2019-08-27T16:45:38Z")

</div>

I think you should give it the right mail server address and the right account.

```
	curl_easy_setopt(CurlHandler, CURLOPT_URL, "smtp://smtp.test.org:587");
	curl_easy_setopt(CurlHandler, CURLOPT_MAIL_FROM, "<test@test.test.org>");
```

---

<div class="post-metadata">

**Author:** ![6r0m](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/6r0m/32/1194563_2.png) [@6r0m](https://forums.unrealengine.com/u/6r0m)\
**Post date:** [August 27, 2019, 4:51pm UTC](https://forums.unrealengine.com/t/help-how-to-connect-to-a-smtp-server/393627/8 "2019-08-27T16:51:45Z")

</div>

I’m changed it for security reason). I’m successfully test my parameters in standard libcurl example - mails arrived fine. but I can’t understand how to properly define variables instead “#define”

 ![285991-capture.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/5/2/0527af2d6f67a734cdf04077ea31104726cf5079.jpeg)

when I’m using your code - problem in my header because I’m not understood how to properly define some variables in your example.

in source.zip above - I’m include header and cpp with your code.  
If you take a glance - I’m very appreciate it 😉

---

<div class="post-metadata">

**Author:** ![LuooYu](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@LuooYu](https://forums.unrealengine.com/u/LuooYu)\
**Post date:** [August 28, 2019, 2:10am UTC](https://forums.unrealengine.com/t/help-how-to-connect-to-a-smtp-server/393627/9 "2019-08-28T02:10:28Z")

</div>

Sorry, I forget to give you the definition of the context struct.

Here is my plugin, the part of the AsyncAction has some problems, but it can be used as an example of SMTP.

---

<div class="post-metadata">

**Author:** ![6r0m](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/6r0m/32/1194563_2.png) [@6r0m](https://forums.unrealengine.com/u/6r0m)\
**Post date:** [August 28, 2019, 7:45am UTC](https://forums.unrealengine.com/t/help-how-to-connect-to-a-smtp-server/393627/10 "2019-08-28T07:45:32Z")

</div>

I’m very grateful to you! You are awesome!

issue: “Server response: 550 5.7.1 [184.173.153.200 14] Messages missing a valid address in From: 5.7.1 header, or having no From: header, are not accepted.”

solved by:

```
MailMessage.Add(TEXT("From: <"));
MailMessage.Add(MailContext.AuthAccount); // on the mailgun AuthAccount the same as email
MailMessage.Add(TEXT(">\r\n"));

```

about Asynchronous Blueprint Nodes - I think it’s blocking game thread operation, just for execution node asynchronously.

I solved this by creating subclass of FNonAbandonableTask which perform non blocking game thread operation [A new, community-hosted Unreal Engine Wiki - Announcements - Unreal Engine Forums](https://wiki.unrealengine.com/index.php?title=Multi-Threading:_Task_Graph_System)

I attached code of MailBlueprintAsyncAction (h, cpp) also. link text

now everything works fine!  
THANK YOU again!)
