Relays incoming emails to LINE messenger. Inspired by SMTP to Telegram.
Use it as an SMTP server for webcams, selfhosted services, development environments, and as a smarthost to receive emails as LINE notifications.
- Set up your LINE developer account and channel: https://developers.line.biz/en/docs/messaging-api/getting-started/
- Retrieve your user ID and channel access token from the channel in the LINE developers console (Basic Settings->Your user ID; Messaging API-> Channel access token)
- Run
smtp-to-line
in a Docker container by cloning this repository and running this command:
docker run \
--name smtp-to-line \
-e SL_LINE_CHANNEL_ACCESS_TOKEN=<TOKEN> \
-e SL_LINE_USER_ID=<ID> \
$(docker build -q .)
smtp-to-line
listens for incoming SMTP traffic on port 8025
Note: LINE has a 500 per month limit on free messages sent via its API (see Messaging API overview).
Define a custom message template for LINE notifications with the environment variable SL_MESSAGE_TEMPLATE
. Available variables:
{sender}
{recipient}
{subject}
{text}
Default: SL_MESSAGE_TEMPLATE="{subject}\nFrom: {sender}\n\n{text}"
smtp-to-line
can extract images, attachments, and html messages from emails to the folder /smtp-to-line/data
, which can then be hosted with a web server. Define an SL_WEB_ROOT
to define a root URL where these files are hosted.
Example: SL_WEB_ROOT="https://example.com/smtp-to-line/"
Specify the path to a SL_SSL_CERT_FILE
and SL_SSL_KEY_FILE
in PEM format to enable STARTTLS encryption.
Alternatively, smtp-to-line
can use the first certificate in a Traefik resolvers file with the SL_TRAEFIK_CERT_PATH
environment variable.
By default smtp-to-line
will accept any SMTP request and fake successful authentication if credentials are provided. To require real authentication for all requests, provide space-separated uesrnames and passwords in the SL_AUTH
environment variable.
Example: SL_AUTH="user1 password1 user2 password2"
These example docker-compose services enable all features and provide an nginx web server for hosting attachments.
smtp-to-line:
build: https://github.com/sirrahd/smtp-to-line.git
ports:
- "587:8025"
environment:
SL_LINE_CHANNEL_ACCESS_TOKEN: "TOKEN"
SL_LINE_USER_ID: "USERID"
SL_WEB_ROOT: "http://example.com/"
SL_SSL_CERT_FILE: "/certificates/cert.pem"
SL_SSL_KEY_FILE: "/certificates/key.pem"
SL_AUTH: "user1 password1 user2 password2"
volumes:
- "./certificates:/certificates:ro"
- "./web:/smtp-to-line/data"
nginx:
image: docker.io/library/nginx
ports: "80:80"
volumes:
- "./web:/usr/share/nginx/html"