- run
mailrender
server
docker run --rm -ti --shm-size=500m -p 8000:8000 restsend/mailrender
- Render a .eml file:
curl -o output.png -X POST 'http://localhost:8000/mailrender?format=png&device=web' \
-F "content=@example.eml"
Submit the data request in the way of POST
, parameters through urlquery
:
- Parameters of url query:
format
output format:png
andpdf
device
Dimensions of thedevice
page:web
Laptop screen size: 1440 x 900 high-resolution monitoriphone
iPhone Display: 736 x 414 Retina Display
timezone
Show when the email was sent: Default isAmerica/New York
waitload
The seconds to wait for the page to load, the default is60
secondsheadless
Only render email content, default isfalse
textonly
Only render text, if there is html will not render, the default isfalse
author
Author information of picture or PDFwatermark
Show watermark on imageviewport
Viewport (x, y, width, height) for capturing screenshot, such as:0,0,600,800
scale
Scale Page scale factor, default is1
hidpi
Render with hidpi screen, pixelratio*2, default isfalse
- Parameters for form-data:
content
file type, required
- Parse the
eml
file, unpack the attachment and embed files, to ensure that the mail can be displayed normally - Render the email content through
chrome-headless
to get the image/pdf.
If Docker runs mailrender, you need to add --shm-size=500m
to the run parameter of
docker, for example:
docker run --rm -ti --shm-size=500m -p 8000:8000 restsend/mailrender
The following environment variables can be adjusted:
PORT
HTTP server port ,default:8000
SIZELIMIT
Upload file size limit(MB), default:50
AUTHOR
Author info, default:https://github.com/restsend/mailrender
STORE
temporary storage directory, default:/tmp/mailrender
docker run --rm -ti --shm-size=500m -e PORT=8080 -p 8080:8080 restsend/mailrender
We have built-in noto fonts, if you need to modify the fonts, add fonts in fonts/
, and modify conf/local.conf
to configure different font matching
There are two ways to compile mailrender
:
- docker build .
- go mod download && go build .