# Email works on 465 but not on 587

**URL:** <https://community.vikunja.io/t/email-works-on-465-but-not-on-587/1207>\
**Category:** Support\
**Created:** [2 March 2023 16:05 UTC](https://community.vikunja.io/t/email-works-on-465-but-not-on-587/1207 "2023-03-02T16:05:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![rikrdo89](https://community.vikunja.io/user_avatar/community.vikunja.io/rikrdo89/32/1590_2.png) [@rikrdo89](https://community.vikunja.io/u/rikrdo89)\
**Post date:** [2 March 2023 16:05 UTC](https://community.vikunja.io/t/email-works-on-465-but-not-on-587/1207/1 "2023-03-02T16:05:40Z")

</div>

This is more of a comment than a question, in case anyone encounters a similar issue. I was getting an error sending a test email when I used mailer port 587, but I was able to successfully get it to work when I switched to port 465, as in the config below.

```auto
      VIKUNJA_MAILER_ENABLED: 1
      VIKUNJA_MAILER_FORCESSL: 1
      VIKUNJA_MAILER_HOST: smtp.gmail.com
      VIKUNJA_MAILER_PORT: 465
      VIKUNJA_MAILER_USERNAME: myacct@gmail.com
      VIKUNJA_MAILER_PASSWORD: secretapppass

```

Not sure why this is. I have postfix server enabled in the same machine where I have a Vikunja container, and it also uses gmail on port 587 without issues… I wonder if there is a way to enable vikunya to use the postfix server already installed in the machine…

to test the email, I run:

```auto
sudo docker exec vikunja-api-1 /app/vikunja/vikunja testmail recipientemail@gmail.com

```

The error I got on port 587 was:

```auto
Error sending test mail: dial failed: tls: first record does not look like a TLS handshake

```

---

<div class="post-metadata">

**Author:** ![kolaente](https://community.vikunja.io/user_avatar/community.vikunja.io/kolaente/32/5_2.png) [@kolaente](https://community.vikunja.io/u/kolaente)\
**Post date:** [2 March 2023 16:33 UTC](https://community.vikunja.io/t/email-works-on-465-but-not-on-587/1207/2 "2023-03-02T16:33:50Z")

</div>

Did you check if the `forcessl` option makes any difference?

---

<div class="post-metadata">

**Author:** ![rikrdo89](https://community.vikunja.io/user_avatar/community.vikunja.io/rikrdo89/32/1590_2.png) [@rikrdo89](https://community.vikunja.io/u/rikrdo89)\
**Post date:** [2 March 2023 16:51 UTC](https://community.vikunja.io/t/email-works-on-465-but-not-on-587/1207/3 "2023-03-02T16:51:38Z")

</div>

I just did, so port 587 works as long as forcessl is set to 0. I don’t understand the implication of having forcessl set to zero and whether that is a security concern…

So the following combinations work for email:

```auto
VIKUNJA_MAILER_PORT: 587
VIKUNJA_MAILER_FORCESSL: 0

```

OR

```auto
VIKUNJA_MAILER_PORT: 465
VIKUNJA_MAILER_FORCESSL: 1

```

---

<div class="post-metadata">

**Author:** ![kolaente](https://community.vikunja.io/user_avatar/community.vikunja.io/kolaente/32/5_2.png) [@kolaente](https://community.vikunja.io/u/kolaente)\
**Post date:** [2 March 2023 19:49 UTC](https://community.vikunja.io/t/email-works-on-465-but-not-on-587/1207/4 "2023-03-02T19:49:54Z")

</div>

If `forcessl` is set to true, Vikunja will require to get a connection via STARTTLS. If it’s not set, it will still try to establish a connection via STARTTLS, but fall back to an unencrypted connection when that does not work.

---

<div class="post-metadata">

**Author:** ![rikrdo89](https://community.vikunja.io/user_avatar/community.vikunja.io/rikrdo89/32/1590_2.png) [@rikrdo89](https://community.vikunja.io/u/rikrdo89)\
**Post date:** [2 March 2023 20:14 UTC](https://community.vikunja.io/t/email-works-on-465-but-not-on-587/1207/5 "2023-03-02T20:14:38Z")

</div>

Thanks for the explanation. However shouldn’t STARTTLS be able to establish a secure encrypted connection via port 587? Isn’t that the point of using port 587 for SMTPS?.. I guess I don’t understand why that would not work.

---

<div class="post-metadata">

**Author:** ![kolaente](https://community.vikunja.io/user_avatar/community.vikunja.io/kolaente/32/5_2.png) [@kolaente](https://community.vikunja.io/u/kolaente)\
**Post date:** [3 March 2023 14:19 UTC](https://community.vikunja.io/t/email-works-on-465-but-not-on-587/1207/6 "2023-03-03T14:19:16Z")

</div>

Not 100% sure either. I think 587 requires establishing an unencrypted connection and then upgrading that with STARTTLS to a secure one. That won’t work if you configure Vikunja to talk tls direclty.
