Skip to content

Latest commit

 

History

History
29 lines (23 loc) · 2.31 KB

1-docker.md

File metadata and controls

29 lines (23 loc) · 2.31 KB

Run it with Docker

Assuming you have access to a web server with support for Docker, you can use this command to run the service:

docker run -d \
  --name=post-to-email \
  -p 8080:80 \
  -e ALLOW_ORIGIN="*" \
  -e DSN="smtp://user:password@smtp.my-domain.com:port" \
  -e RECIPIENT="Matthias Mullie <my-email@example.com>" \
  matthiasmullie/post-to-email

This will pull the matthiasmullie/post-to-email image from Docker Hub and run it exposed on port 8080 with a hard-coded DSN and RECIPIENT.

  • For ALLOW_ORIGIN, enter the domain you want to accept requests from (e.g. https://my-website.com), or * to allow requests from anywhere
    • To prevent abuse, I'd recommend locking things down to a specific domain unless there's a good reason not to
    • Read up on Access-Control-Allow-Origin if you want to learn more
  • DSN should be your SMTP connection string
    • This usually takes the form of smtp://<username>:<password>@<smtp-server>:<port>
    • For more information, check with your email provider. Here's a link to Gmail and Outlook's documentation
      • Note: If your email account is secured with multi-factor authentication, you may need to create an app password. Here's some documentation for Gmail and Outlook
  • RECIPIENT is the email address you want to receive emails at
    • This can take either my-email@example.com or My Name <my-email@example.com> format

While it's possible to include these variables in the data your form will submit, it makes sense to hard-code some of these in the web service, to prevent others from being able to (ab)use your service.

Note: don't forget to replace below DSN & RECIPIENT variables with your own. Check configuration to see what other environment variables are available.