cURL
PHP
Node.js
Python
Copiar
curl -X POST https://api.mailgrid.net.br/sendmail/ \
-H "Content-Type: application/json" \
-d '{
"host_smtp" : "HOST-SMTP" ,
"usuario_smtp" : "USUARIO-SMTP" ,
"senha_smtp" : "SENHA-SMTP" ,
"emailRemetente" : "nfe@suaempresa.com.br" ,
"nomeRemetente" : "Sua Empresa" ,
"emailDestino" : ["cliente@dominio.com.br" ],
"assunto" : "Sua NF-e 004.812" ,
"mensagem" : "<p>Segue sua nota fiscal.</p>" ,
"mensagemTipo" : "html"
}'
$curl = curl_init ();
curl_setopt_array ($curl , array (
CURLOPT_URL => 'https://api.mailgrid.net.br/sendmail/' ,
CURLOPT_RETURNTRANSFER => true ,
CURLOPT_CUSTOMREQUEST => 'POST' ,
CURLOPT_HTTPHEADER => array ('Content-Type: application/json' ),
CURLOPT_POSTFIELDS => json_encode (array (
'host_smtp' => 'HOST-SMTP' ,
'usuario_smtp' => 'USUARIO-SMTP' ,
'senha_smtp' => 'SENHA-SMTP' ,
'emailRemetente' => 'nfe@suaempresa.com.br' ,
'emailDestino' => array ('cliente@dominio.com.br' ),
'assunto' => 'Sua NF-e 004.812' ,
'mensagem' => '<p>Segue sua nota fiscal.</p>' ,
)),
));
$response = curl_exec ($curl );
curl_close ($curl );
const axios = require ('axios' );
axios.post('https://api.mailgrid.net.br/sendmail/' , {
host_smtp: 'HOST-SMTP' ,
usuario_smtp: 'USUARIO-SMTP' ,
senha_smtp: 'SENHA-SMTP' ,
emailRemetente: 'nfe@suaempresa.com.br' ,
emailDestino: ['cliente@dominio.com.br' ],
assunto: 'Sua NF-e 004.812' ,
mensagem: '<p>Segue sua nota fiscal.</p>' ,
mensagemTipo: 'html' ,
}, { headers: { 'Content-Type' : 'application/json' } })
.then(res => console.log(res.data))
.catch(err => console.error(err.message));
import requests
resp = requests.post(
"https://api.mailgrid.net.br/sendmail/" ,
headers={"Content-Type" : "application/json" },
json={
"host_smtp" : "HOST-SMTP" ,
"usuario_smtp" : "USUARIO-SMTP" ,
"senha_smtp" : "SENHA-SMTP" ,
"emailRemetente" : "nfe@suaempresa.com.br" ,
"emailDestino" : ["cliente@dominio.com.br" ],
"assunto" : "Sua NF-e 004.812" ,
"mensagem" : "<p>Segue sua nota fiscal.</p>" ,
},
)
print (resp.json())
200 Resposta
[
{
"status" : "MSG ENVIADA" ,
"codigo" : "200" ,
"id" : "1rDPyZ-0006kJ-2N" ,
"to" : "cliente@dominio.com.br"
}
]