domodwyer / mailyak

An elegant MIME/SMTP email library with support for attachments

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[question] client config when calling inside of docker

ghstahl opened this issue · comments

Is there a special way to configuration for inside of docker for the client?
 
https://github.com/rnwood/smtp4dev/wiki/Configuring-Clients

I am able to send an email when I run smtp4dev in docker from outside using localhost:25

	mail := mailyak.New(
		"localhost:25",
		smtp.PlainAuth(
			"",
			"",
			"",
			"localhost")

Inside Docker.

	mail := mailyak.New(
		"smtp4dev:25",
		smtp.PlainAuth(
			"",
			"",
			"",
			"smtp4dev")

When I run my app inside of docker I configure it to use smtp4dev:25
I get the following error sending "unencrypted connection"

smtp4dev:
    extends:
      file: ./docker-compose-common.yml
      service: micro
    image: rnwood/smtp4dev:v3
    restart: always
    ports:
      # Change the number before : to the port the web interface should be accessible on
      - "${SMTP4DEV_WEB_PORT}:80"
      # Change the number before : to the port the SMTP server should be accessible on
      - "25:25"
      # Change the number before : to the port the IMAP server should be accessible on
      - "143:143"
    volumes:
      # This is where smtp4dev stores the database..
      - smtp4dev-data:/smtp4dev
    environment:
      # Uncomment to customise these settings

      #Specifies the virtual path from web server root where SMTP4DEV web interface will be hosted. e.g. "/" or "/smtp4dev"
      #- ServerOptions__BasePath=/smtp4dev

      #Specifies the server hostname. Used in auto-generated TLS certificate if enabled.
      - ServerOptions__HostName=smtp4dev

      #Locks settings from being changed by user via web interface
      #- ServerOptions__LockSettings=true

      #Specifies the path where the database will be stored relative to APPDATA env var on Windows or XDG_CONFIG_HOME on non-Windows. Specify "" to use an in memory database.
      #- ServerOptions__Database=database.db

      #Specifies the number of messages to keep
      #- ServerOptions__NumberOfMessagesToKeep=100

      #Specifies the number of sessions to keep
      #- ServerOptions__NumberOfSessionsToKeep=100

      #Specifies the TLS mode to use. None=Off. StartTls=On demand if client supports STARTTLS. ImplicitTls=TLS as soon as connection is established.
      #- ServerOptions__TlsMode=None

      #Specifies the TLS certificate to use if TLS is enabled/requested. Specify "" to use an auto-generated self-signed certificate (then see console output on first startup)
      #- ServerOptions__TlsCertificate=

      #Sets the name of the SMTP server that will be used to relay messages or "" if messages should not be relayed
      #- RelayOptions__SmtpServer=

      #Sets the port number for the SMTP server used to relay messages.
      #- RelayOptions__SmtpPort=25

      #Specifies a comma separated list of recipient addresses for which messages will be relayed. An empty list means that no messages are relayed.
      #- RelayOptions__AllowedEmailsString=

      #Specifies the address used in MAIL FROM when relaying messages. (Sender address in message headers is left unmodified). The sender of each message is used if not specified.
      #- RelayOptions__SenderAddress=

      #The username for the SMTP server used to relay messages. If "" no authentication is attempted.
      #- RelayOptions__Login=

      #The password for the SMTP server used to relay messages
      #- RelayOptions__Password=

      #Specifies the port the IMAP server will listen on - allows standard email clients to view/retrieve messages
      #"ServerOptions__ImapPort"=143
commented

Hey @ghstahl,

There's no special requirement from mailyak's point of view so I'll probably close this, but looking at what you pasted this seems relevant:

      #Specifies the TLS mode to use. None=Off. StartTls=On demand if client supports STARTTLS. ImplicitTls=TLS as soon as connection is established.
      #- ServerOptions__TlsMode=None

The "unencrypted connection" sounds like it's going to be related to TLS - are you using different smtp4dev configs when running locally vs. in docker? I'd check the configs match next 👍

Same smpt4dev instance running. Just in docker.

I am running ServerOptions__TlsMode=None

from outside, I send an email to localhost:25.
Works fine.

From inside, same app, configured exactly the same, except smtp4dev:25, the error I get is "unencrypted connection"

Still hunting.

This is a smtp4dev thing in docker and not mailyak.
I can send to sendgrid from inside docker.

mail := mailyak.New(
        "smtp.sendgrid.net:587",
        smtp.PlainAuth(
            "",
            "apikey", // Set your username to "apikey"
            "<YOUR_API_KEY>", // Replace with your actual SendGrid API key
            "smtp.sendgrid.net",
        ),
    )