mjmlio / mjml

MJML: the only framework that makes responsive-email easy
https://mjml.io
MIT License
17.08k stars 960 forks source link

SSL Certificate Error #2156

Closed jeffersonrabb closed 3 years ago

jeffersonrabb commented 3 years ago

Describe the bug Newspack Newsletters users are getting this response when making API requests to https://api.mjml.io/v1/render:

{"errors":{"http_request_failed":["cURL error 60: SSL certificate problem: unable to get local issuer certificate"]},"error_data":[]}

This looks identical to https://github.com/mjmlio/mjml/issues/2114

yucomds commented 3 years ago

Any suggestion for this? We have a lot of production websites relies on your api !

yucomds commented 3 years ago

For people using the API in PHP software you could "solve" by installing mjml cli.

Run this :

npm install -g mjml

Then in your code you can make something like this :

$input_file     = "/tmp/".time()."_input.mjml";
$output_file    = "/tmp/".time()."_output.mjml";

file_put_contents($input_file, $mjml);

$res = exec("mjml {$input_file} -o {$output_file}", $error, $return_var);

// print_r($res);
// print_r($error);
// print_r($return_var);

$html = file_get_contents($output_file);   

unlink($input_file);
unlink($output_file);
ngarnier commented 3 years ago

Sorry, the issue should be fixed now.

We've always been transparent about the API but I'll reiterate. This API is a complimentary, free-to-use API without any SLA attached as you would expect (considering it's 100% free). I do not recommend to anyone to use it in production without any fallback, and certainly not if it can block other processes such as a message from being sent.

This is even more true now that we released the mjml-browser package allowing anyone to run MJML browser-side easily.

pennal commented 3 years ago

I agree that there is no mention of guarantee of service of any sort, but there are also no warnings on the signup page. Maybe add a simple banner stating that it should only be used for testing purposes? The fact that some people rely on this service in prod shows that there is confusion which could easily be avoided.

Also, what do you mean by fallback? All the methods you provide are strictly JS based, which may work for some but for many are a burden to deal with. Could it be time to reconsider #2117 ?

iRyusa commented 3 years ago

I'm not sure we'll ever commit to maintain a docker image.

You can just start it with a relatively simple express application :

const express = require('express')
const app = express()
const port = 3000
const mjml2html = require('mjml')

app.get('/render', (req, res) => {
  res.send(JSON.stringify(mjml2html(req.body)))
})

app.listen(port, () => {
  console.log(`Example app listening at http://localhost:${port}`)
})