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

Lemmy Support

4634 readers
4 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.

top 17 comments
sorted by: hot top controversial new old
[–] howdy@thesimplecorner.org 2 points 1 year ago (1 children)

following.... similar question!

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

I edited my original post with what actually worked for me in the end.

[–] howdy@thesimplecorner.org 1 points 1 year ago

Right on... Thank you. My VPS is blocking all smtp ports so I either have to get really creative or move hosts it's looking like. 😁

[–] hsl@wayfarershaven.eu 0 points 1 year ago
[–] matejc@matejc.com 1 points 1 year ago (1 children)

My instance had the same problem, the problem was that Hetzner (where I host my server) by default is not permitting outbound smtp ports. For me the solution was to use alternative port and even that a starttls alternative port which AWS SES luckily supports (that is what I am using for smtp server). Alternative would be also to just ask Hetzner to unblock the port (people have reported success with this method).

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

Actually it seems that port 587 is open (starttls) while port 465 (tls) is closed. I can connect to port 587 on my email server from my Hetzner instance (im also using them).

But how should the config look like to forward emails? How does your config look like?

[–] matejc@matejc.com 2 points 1 year ago

Btw, I do not use postfix

[–] matejc@matejc.com 2 points 1 year ago

if you use starttls, just use tls_type: "starttls" in your config

[–] hsl@wayfarershaven.eu 1 points 1 year ago* (last edited 1 year ago)

I was able to get Brevo working on Hetzner with the following block:

  email: {
    smtp_server: "smtp-relay.sendinblue.com:587"
    smtp_login: "your_email"
    smtp_password: "smtp_key"
    smtp_from_address: "your_email"
    tls_type: "starttls"
  }

Interestingly, it wasn't working when I gave up and went to bed. I happened to do something on the instance today and much to my surprise, an email came through. Maybe Brevo holds the emails/doesn't immediately allow SMTP?

if that hadn't worked, my next step was going to test sending email through the console as described in another comment.

[–] slashzero@hakbox.social 1 points 1 year ago (1 children)

Hi there! Going to take a minute to read through your post, as I banged my head against a the SMTP setup wall for several hours.

But while I do that, assuming you are using the docker method, did you add a secondary external network to the lemmy container in docker-compose.yml? Your email setup looks fine, but without adding the secondary external network your lemmy instance can’t make outgoing calls (federation won’t work either).

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

Federation works fine, the only thing that doesnt is the email sending for some reason. :/

[–] slashzero@hakbox.social 1 points 1 year ago* (last edited 1 year ago) (2 children)

Can you check lemmy and postfix logs?

Postfix logs are in /var/log/mail

[–] mrmanager@lemmy.today 1 points 1 year ago

I checked the logs for postfix (since I use docker I can just do "docker logs") but no errors.

It all silently fails. I guess it has to do with email servers dropping the emails. I will look into using some other email server, maybe on aws if that works for other people.

But I have verified that I can connect to the email server with starttls, and even base64 encoded my username and password and did an interactive "Auth login" session with the email server. All was fine, I was authenticated.

So probably something with the reply from, maybe.. Very confusing.

[–] mrmanager@lemmy.today 0 points 1 year ago (1 children)

I checked the logs for postfix (since I use docker I can just do "docker logs") but no errors.

It all silently fails. I guess it has to do with email servers dropping the emails. I will look into using some other email server, maybe on aws if that works for other people.

But I have verified that I can connect to the email server with starttls, and even base64 encoded my username and password and did an interactive "Auth login" session with the email server. All was fine, I was authenticated.

So probably something with the reply from, maybe.. Very confusing.

[–] slashzero@hakbox.social 1 points 1 year ago* (last edited 1 year ago)

You are hosting your own postfix, right? Most mail servers will just outright reject your messages. You can add your site's certs to postfix, so that your mail is not clear text, and that would allow some to go through (but gmail would still block all of them).

What I ended up doing was signing up for brevo.com and their free tier allows 300 mail messages every 24 hours. Another option would be to use gmail's smtp relay, which I think allows 300 - 500 emails per day, or something long those lines.

brevo.com is actually pretty nice as it gives you stats on mail click throughs, etc.

load more comments
view more: next ›