# ZF2 Mail could not open socket

**URL:** <https://discourse.laminas.dev/t/zf2-mail-could-not-open-socket/348>\
**Category:** Components & MVC\
**Created:** [November 2, 2017, 3:09am UTC](https://discourse.laminas.dev/t/zf2-mail-could-not-open-socket/348 "2017-11-02T03:09:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Temmy\_Alex](https://avatars.discourse-cdn.com/v4/letter/t/e95f7d/32.png) [@Temmy\_Alex](https://discourse.laminas.dev/u/Temmy_Alex)\
**Post date:** [November 2, 2017, 3:09am UTC](https://discourse.laminas.dev/t/zf2-mail-could-not-open-socket/348/1 "2017-11-02T03:09:35Z")

</div>

Hi i have problem when send mail with ZF2

![error_socket](https://canada1.discourse-cdn.com/flex032/uploads/zendframework/original/1X/3ac7f57cbb4343f3ce3170f913e0b69cf3517fce.png)

can help with this case?

here is my code

[https://codeshare.io/G6x71Q](https://codeshare.io/G6x71Q)

Thanks

---

<div class="post-metadata">

**Author:** ![xtreamwayz](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/xtreamwayz/32/27_2.png) [@xtreamwayz](https://discourse.laminas.dev/u/xtreamwayz)\
**Post date:** [November 2, 2017, 9:23am UTC](https://discourse.laminas.dev/t/zf2-mail-could-not-open-socket/348/2 "2017-11-02T09:23:54Z")

</div>

You are trying to send an email to `$smtpOptions->setHost('dnr.mail.host')`. I’m pretty sure `dnr.mail.host` is not a valid host.

---

<div class="post-metadata">

**Author:** ![Temmy\_Alex](https://avatars.discourse-cdn.com/v4/letter/t/e95f7d/32.png) [@Temmy\_Alex](https://discourse.laminas.dev/u/Temmy_Alex)\
**Post date:** [November 2, 2017, 9:36am UTC](https://discourse.laminas.dev/t/zf2-mail-could-not-open-socket/348/3 "2017-11-02T09:36:27Z")

</div>

You’re right  
it already solved  
my host is not valid
