this post was submitted on 11 Jun 2023
4 points (100.0% liked)

Lemmy Support

4656 readers
15 users here now

Support / questions about Lemmy.

Matrix Space: #lemmy-space

founded 5 years ago
MODERATORS
 

I cant get my email sending to work on my instance. After trying for hours, i wanted to ask for some support here since im quite stuck and dont understand.

I installed Lemmy using ansible so everything is set up in a very standard way - except email.

I want my instance to send email to an external smtp server (Fastmail) whenever there is a need to send an email (user registration, password reset, etc).

Currently the email settings in lemmy.hjson looks like this:

  email: {
    smtp_server: "postfix:25"
    smtp_login: "abc@fastmail.se"
    smtp_password: "fastmail_user_password_here"
    smtp_from_address: "noreply@lemmy.today"
    tls_type: "tls"
  }

It seems like i need to have postfix:25 as the smtp server. What i really want is to put smtp.fastmail.com:465 here since thats what i want to use to send email. But that doesnt seem to work.

So I understand I need to send email through postfix, but then I wonder, how should the config look like to send emails to smtp.fastmail.com on port 465 (which is what they have on fastmail), with a specific username and password used on the fastmail server?

I think a lot of people are having issues with the email part of the setup, judging from the many reports of spinning buttons on user signup... this is a very likely reason, specially since there is no error message to the user.

Please help me sort this out, how should i configure this?

EDIT:

Ok after a lot of experiments and help from people below, this was the solution.

  email: {
    smtp_server: "smtp.fastmail.com:587"
    smtp_login: "my_email@fastmail.com"
    smtp_password: "password"
    smtp_from_address: "my_email@fastmail.com"
    tls_type: "starttls"
  }

Using this, email sending finally works. I couldnt use something else in the smtp_from_address. Which means my real email gets shown to users, so I will probably create another email address for this purpose completely.

Also specific to Hetzner instances, they dont block port 587 so you can use that with starttls.

you are viewing a single comment's thread
view the rest of the comments
[–] cablepick@lemmy.cablepick.net 0 points 1 year ago* (last edited 1 year ago) (1 children)

Make sure you can connect from your server to ensure firewall rules, passwords, and SSL type are accurate.

openssl s_client -connect smtp.fastmail.com:465 -tls smtp

More directions here as you need to encode your username and password to login from the shell: https://www.stevenrombauts.be/2018/12/test-smtp-with-telnet-or-openssl/

You can replace postfix:25 with smtp.fastmail.com:465 in the config. Verify that you need tls and not starttls as the ssl type.

If this is docker then you need to ensure the container can route to their server and port. I don’t use docker so I can’t help you there but I think it’s something about internal vs external bridge.

[–] smartwater0897@lemmy.ml 1 points 1 year ago (1 children)

This gets a connection:

openssl s_client -connect smtp.fastmail.com:587 -starttls smtp

So its open on port 587 to the email server, but I dont get any emails arriving there...

[–] cablepick@lemmy.cablepick.net 1 points 1 year ago (1 children)

Did you try sending an email through OpenSSL using shell commands? Lemmy has no test email function so you need to be sure your credentials are correct.

It’s not uncommon for email servers to prevent you from sending as someone else even if you authenticate against your primary account. When using the OpenSSL shell commands it should end a successful test send with 250 ok queued or display an error like from not owned by primary account.

[–] mrmanager 1 points 1 year ago (1 children)

I got as far as connecting and authenticating, that works fine with starttls and port 587. I didn't actually send an email though, maybe I should try that and put different things in the smtp_from field, if possible?

[–] cablepick@lemmy.cablepick.net 1 points 1 year ago (1 children)

Try sending an email through there. That will tell you right away if you mail server will allow to you use the from address you want to. The message that it responds with is the message that lemmy, or whatever relay, would be logging anyways.

[–] smartwater0897@lemmy.ml 1 points 1 year ago

Email actually started working now, I think maybe I was blocked for a while due to my attempts to get things working. Will edit my top post to make sure others can find the result of this thread.

Thanks!