lemmy icon indicating copy to clipboard operation
lemmy copied to clipboard

SMTP Server Error: Cannot Send Emails

Open cachho opened this issue 1 year ago • 5 comments

  • [X] Did you check to see if this issue already exists?
  • [X] Is this only a single bug? Do not put multiple bugs in one issue.
  • [X] Is this a question or discussion? Don't use this, use https://lemmy.ml/c/lemmy_support .
  • [X] Is this a UI / front end issue? Use the lemmy-ui repo.

Issue Summary

Emails cannot be sent via SMTP Server. Swaks with the same details works.

Steps to Reproduce

  1. This command works in SWAKS and I get the email: swaks --to [email protected] --from [email protected] --server smtp-relay.sendinblue.com --port 587 --auth-user [email protected] --auth-password SECRET
  2. I have added this block to my lemmy.hjson
  email: {
    # Hostname and port of the smtp server
    smtp_server: "smtp-relay.sendinblue.com:587"
    # Login name for smtp server
    smtp_login: "[email protected]"
    # Password to login to the smtp server
    smtp_password: "SECRET"
    # Address to send emails from, eg "[email protected]"
    smtp_from_address: "[email protected]"
    # Whether or not smtp connections should use tls. Can be none, tls, or starttls
    tls_type: "none"
  }
  1. I navigate to my instance at lemmy.my.instance
  2. I test via password reset. I get the following error in the docker-compose logs:
lemmy_1     | 2023-06-13T05:48:46.124555Z ERROR HTTP request{http.method=GET http.scheme="http" http.host=lemmy.my.instance http.target=/api/v3/ws otel.kind="server" request_id=93a522f6-adf4-4717-ad55-62d96290da51 http.status_code=101 otel.status_code="OK"}: lemmy_server::api_routes_websocket: email_send_failed: Connection error: failed to lookup address information: Try again
lemmy_1     |    0: lemmy_api::local_user::reset_password::perform
lemmy_1     |              at crates/api/src/local_user/reset_password.rs:15
lemmy_1     |    1: lemmy_server::root_span_builder::HTTP request
lemmy_1     |            with http.method=GET http.scheme="http" http.host=lemmy.my.instance http.target=/api/v3/ws otel.kind="server" request_id=93a522f6-adf4-4717-ad55-62d96290da50 http.status_code=101 otel.status_code="OK"
lemmy_1     |              at src/root_span_builder.rs:16

Technical details

  • Please post your log: sudo docker-compose logs > lemmy_log.out.
Attaching to lemmy_proxy, lemmy_ui, lemmy_lemmy, lemmy_postgres, lemmy_pictrs
proxy_1     | /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
proxy_1     | /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
proxy_1     | /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
proxy_1     | 10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
proxy_1     | 10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
proxy_1     | /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
proxy_1     | /docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
proxy_1     | /docker-entrypoint.sh: Configuration complete; ready for start up
proxy_1     | 172.22.0.13 - - [13/Jun/2023:05:48:34 +0000] "GET /login HTTP/1.1" 200 7119 "https://lemmy.my.instance/communities" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36"
proxy_1     | 172.22.0.13 - - [13/Jun/2023:05:48:35 +0000] "GET /api/v3/ws HTTP/1.1" 101 0 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36"
proxy_1     | 172.22.0.13 - - [13/Jun/2023:05:48:35 +0000] "GET /static/assets/manifest.webmanifest HTTP/1.1" 304 0 "https://lemmy.my.instance/login" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36"
lemmy_ui    | Inferno is in development mode.
lemmy_ui    | Inferno is in development mode.
lemmy_ui    | Inferno is in development mode.
lemmy_ui    | httpbase: http://lemmy:8536
lemmy_ui    | wsUri: ws://localhost:1236/api/v3/ws
lemmy_ui    | isHttps: false
lemmy_ui    | http://0.0.0.0:1234
postgres_1  | 
postgres_1  | PostgreSQL Database directory appears to contain a database; Skipping initialization
postgres_1  | 
postgres_1  | 2023-06-13 05:48:17.861 UTC [1] LOG:  starting PostgreSQL 15.3 on x86_64-pc-linux-musl, compiled by gcc (Alpine 12.2.1_git20220924-r10) 12.2.1 20220924, 64-bit
postgres_1  | 2023-06-13 05:48:17.861 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
postgres_1  | 2023-06-13 05:48:17.861 UTC [1] LOG:  listening on IPv6 address "::", port 5432
postgres_1  | 2023-06-13 05:48:17.862 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgres_1  | 2023-06-13 05:48:17.864 UTC [23] LOG:  database system was shut down at 2023-06-13 05:47:47 UTC
postgres_1  | 2023-06-13 05:48:17.868 UTC [1] LOG:  database system is ready to accept connections
pictrs_1    | 2023-06-13T05:48:17.768144Z  INFO restructure{store=FileStore { path_gen: "generator", root_dir: "/mnt" }}: pict_rs::store::file_store::restructure: new
pictrs_1    | 2023-06-13T05:48:17.768196Z  INFO restructure{store=FileStore { path_gen: "generator", root_dir: "/mnt" }}: pict_rs::store::file_store::restructure: close time.busy=27.7µs time.idle=26.6µs
pictrs_1    | 2023-06-13T05:48:17.768621Z  INFO actix_server::builder: Starting 4 workers
pictrs_1    | 2023-06-13T05:48:17.768644Z  INFO actix_server::server: Actix runtime found; starting in Actix runtime
lemmy_1     | 2023-06-13T05:48:18.209919Z  INFO lemmy_db_schema::utils: Running Database migrations (This may take a long time)...
lemmy_1     | 2023-06-13T05:48:18.225251Z  INFO lemmy_db_schema::utils: Database migrations complete.
lemmy_1     | 2023-06-13T05:48:18.235337Z  INFO lemmy_server::code_migrations: Running user_updates_2020_04_02
lemmy_1     | 2023-06-13T05:48:18.245465Z  INFO lemmy_server::code_migrations: 0 person rows updated.
lemmy_1     | 2023-06-13T05:48:18.245672Z  INFO lemmy_server::code_migrations: Running community_updates_2020_04_02
lemmy_1     | 2023-06-13T05:48:18.248864Z  INFO lemmy_server::code_migrations: 0 community rows updated.
lemmy_1     | 2023-06-13T05:48:18.248945Z  INFO lemmy_server::code_migrations: Running post_updates_2020_04_03
lemmy_1     | 2023-06-13T05:48:18.250717Z  INFO lemmy_server::code_migrations: 0 post rows updated.
lemmy_1     | 2023-06-13T05:48:18.250811Z  INFO lemmy_server::code_migrations: Running comment_updates_2020_04_03
lemmy_1     | 2023-06-13T05:48:18.259760Z  INFO lemmy_server::code_migrations: 0 comment rows updated.
lemmy_1     | 2023-06-13T05:48:18.259889Z  INFO lemmy_server::code_migrations: Running private_message_updates_2020_05_05
lemmy_1     | 2023-06-13T05:48:18.261068Z  INFO lemmy_server::code_migrations: 0 private message rows updated.
lemmy_1     | 2023-06-13T05:48:18.261199Z  INFO lemmy_server::code_migrations: Running post_thumbnail_url_updates_2020_07_27
lemmy_1     | 2023-06-13T05:48:18.262270Z  INFO lemmy_server::code_migrations: 0 Post thumbnail_url rows updated.
lemmy_1     | 2023-06-13T05:48:18.262430Z  INFO lemmy_server::code_migrations: Running apub_columns_2021_02_02
lemmy_1     | 2023-06-13T05:48:18.263493Z  INFO lemmy_server::code_migrations: Running instance_actor_2021_09_29
lemmy_1     | 2023-06-13T05:48:18.274804Z  INFO lemmy_server::code_migrations: Running regenerate_public_keys_2022_07_05
lemmy_1     | 2023-06-13T05:48:18.275794Z  INFO lemmy_server::code_migrations: Running initialize_local_site_2022_10_10
lemmy_1     | federation enabled, host is lemmy.my.instance
lemmy_1     | Starting http server at 0.0.0.0:8536
lemmy_1     | 2023-06-13T05:48:18.299349Z  INFO lemmy_server::scheduled_tasks: Updating active site and community aggregates ...
lemmy_1     | 2023-06-13T05:48:18.320336Z  INFO lemmy_server::scheduled_tasks: Done.
lemmy_1     | 2023-06-13T05:48:18.320351Z  INFO lemmy_server::scheduled_tasks: Updating banned column if it expires ...
lemmy_1     | 2023-06-13T05:48:18.321220Z  INFO lemmy_server::scheduled_tasks: Reindexing table concurrently post_aggregates ...
lemmy_1     | 2023-06-13T05:48:18.351093Z  INFO lemmy_server::scheduled_tasks: Done.
lemmy_1     | 2023-06-13T05:48:18.351105Z  INFO lemmy_server::scheduled_tasks: Reindexing table concurrently comment_aggregates ...
lemmy_1     | 2023-06-13T05:48:18.358209Z  INFO lemmy_server::scheduled_tasks: Done.
lemmy_1     | 2023-06-13T05:48:18.358221Z  INFO lemmy_server::scheduled_tasks: Reindexing table concurrently community_aggregates ...
lemmy_1     | 2023-06-13T05:48:18.366040Z  INFO lemmy_server::scheduled_tasks: Done.
lemmy_1     | 2023-06-13T05:48:18.366108Z  INFO lemmy_server::scheduled_tasks: Clearing old activities...
lemmy_1     | 2023-06-13T05:48:18.368808Z  INFO lemmy_server::scheduled_tasks: Done.
lemmy_1     | 2023-06-13T05:48:46.124555Z ERROR HTTP request{http.method=GET http.scheme="http" http.host=lemmy.my.instance http.target=/api/v3/ws otel.kind="server" request_id=93a522f6-adf4-4717-ad55-62d96290da50 http.status_code=101 otel.status_code="OK"}: lemmy_server::api_routes_websocket: email_send_failed: Connection error: failed to lookup address information: Try again
lemmy_1     |    0: lemmy_api::local_user::reset_password::perform
lemmy_1     |              at crates/api/src/local_user/reset_password.rs:15
lemmy_1     |    1: lemmy_server::root_span_builder::HTTP request
lemmy_1     |            with http.method=GET http.scheme="http" http.host=lemmy.my.instance http.target=/api/v3/ws otel.kind="server" request_id=93a522f6-adf4-4717-ad55-62d96290da50 http.status_code=101 otel.status_code="OK"
lemmy_1     |              at src/root_span_builder.rs:16
  • What OS are you trying to install lemmy on? Debian
  • Any browser console errors? None

cachho avatar Jun 13 '23 05:06 cachho

the main lemmy server is only in the lemmy internal docker network, it can't do name resolution and if the mail server isn't also in the lemmy internal network, it can't send emails either. kinda weird way to handle this.

At least that's how it looks like from my perspective.

Edit: wtf. I literally just wget-ed the docker-compose file a few hours ago and it didn't have the change that put lemmy into the lemmyexternalproxy network, despite it having been committed for 5 days now. github caching? Edit2: OK nvm I downloaded the prod files, and the ones where they added the external network are in dev.

insunaa avatar Jun 13 '23 09:06 insunaa

the main lemmy server is only in the lemmy internal docker network, it can't do name resolution and if the mail server isn't also in the lemmy internal network, it can't send emails either. kinda weird way to handle this.

At least that's how it looks like from my perspective.

do you have a working examle? This thread is all I have to go by, and I couldn't make it work the first time I tried: https://lemmy.eus/post/30313?scrollToComments=true

I don't insist on using sendinblue, but if possible I would like a plug and play solution and not mess around with DMARC, DKIM, rDNS and all that stuff.

cachho avatar Jun 13 '23 15:06 cachho

I used an IP address of the relay on my local network, worked fine.

XtremeOwnageDotCom avatar Jun 17 '23 17:06 XtremeOwnageDotCom

@cachho sorry, I forgot to reply

  lemmy:
    image: dessalines/lemmy:0.17.4
    hostname: lemmy
    networks:
      - lemmyinternal
      - lemmyexternalproxy
    restart: always
    environment:
      - RUST_LOG="warn,lemmy_server=info,lemmy_api=info,lemmy_api_common=info,lemmy_api_crud=info,lemmy_apub=info,lemmy_db_schema=info,lemmy_db_views=info,lemmy_db_views_actor=info,lemmy_db_views_moderator=info,lemmy_routes=info,lemmy_utils=info,lemmy_websocket=info"
    volumes:
      - ./lemmy.hjson:/config/config.hjson
    depends_on:
      - postgres
      - pictrs

This basically. Note the "networks" part.

insunaa avatar Jun 21 '23 10:06 insunaa

Looks like, with #3356, network configs were removed again. How can we get external network connectivity from the Lemmy container?

HanSooloo avatar Jul 04 '23 10:07 HanSooloo