Created
December 26, 2013 17:17
-
-
Save arthursoares/8136245 to your computer and use it in GitHub Desktop.
Cada $_POST é um "name" que algum <INPUT> dentro do form tem. Você vai precisar criar uma conta no mandrill (free) e pegar a API Key. Você customiza abaixo conforme os campos e os dois arquivos que você precisar. :)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form action="post.php" method="post" role="form" id="form-contato"> | |
<div class="form-group"> | |
<div class="col-sm-12 col-md-6"> | |
<input type="text" name="FIRST_NAME" class="form-control" placeholder="Nome *"/> | |
</div> | |
<div class="col-sm-12 col-md-6"> | |
<input type="tel" name="LAST_NAME" class="form-control" placeholder="Sobrenome *"/> | |
</div> | |
</div> | |
<div class="form-group"> | |
<div class="col-sm-12 col-md-6"> | |
<input type="text" name="ORGANISATION_NAME" class="form-control" placeholder="Empresa"/> | |
</div> | |
<div class="col-sm-12 col-md-6"> | |
<input type="tel" name="PHONE" class="form-control" placeholder="Telefone *"/> | |
</div> | |
</div> | |
<div class="form-group"> | |
<div class="col-sm-12 col-md-12"> | |
<input type="email" name="EMAIL" class="form-control" placeholder="E-mail *"/> | |
</div> | |
</div> | |
<div class="form-group"> | |
<div class="col-sm-12 col-md-12"> | |
<select class="form-control" name="LEAD"> | |
<option value="" disabled selected>Quero mais informações sobre:</option> | |
<option value="Estações colaborativas">Estações colaborativas</option> | |
<option value="Estúdios">Estúdios privativos</option> | |
<option value="Locações">Locação para eventos</option> | |
<option value="Outros assuntos">Outros assuntos</option> | |
</select> | |
</div> | |
</div> | |
<div class="form-group"> | |
<div class="col-sm-12 col-md-12"> | |
<button type="submit" class="btn btn-primary btn-block botao-enviar" data-loading-text="Enviando pedido…" data-completo-text="Pedido enviado com sucesso." data-erro-text="Ocorreu algum erro, seremos notificados.">Clique para enviar</button> | |
</div> | |
</div> | |
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$uri = 'https://mandrillapp.com/api/1.0/messages/send.json'; | |
$mensagem = '<html><body><h1>Novo Cadastro pelo site</h1><p>Nome:' . $_POST['FIRST_NAME'] . ' ' . $_POST['LAST_NAME'] .'</p><p>E-mail: '. $_POST['EMAIL'] .'</p><p>Telefone: ' . $_POST['PHONE'] . '</p><p>Interesse em: ' . $_POST['LEAD'] . '</p></body></html>'; | |
$mensagem_txt = 'Nome: ' . $_POST['FIRST_NAME'] . ' ' . $_POST['LAST_NAME'] .'/n E-mail: '. $_POST['EMAIL'] .'/n Telefone: ' . $_POST['PHONE'] . '/n Interesse em: ' . $_POST['LEAD']; | |
$postString = '{ | |
"key": "g54OsHRh9Hj6G4bIDe0DEw", | |
"message": { | |
"html": "' . $mensagem . '", | |
"text": "' . $mensagem_txt .'", | |
"subject": "NEX Batel: Novo cadastro", | |
"from_email": "contato@nexcoworking.com.br", | |
"from_name": "NEX Hotsite", | |
"to": [ | |
{ | |
"email": "comercial@galvao.com.br", | |
"name": "Comercial Galvao: NEX" | |
} | |
], | |
"headers": { | |
}, | |
"track_opens": true, | |
"track_clicks": true, | |
"auto_text": true, | |
"url_strip_qs": true, | |
"preserve_recipients": true, | |
"merge": true, | |
"global_merge_vars": [ | |
], | |
"merge_vars": [ | |
], | |
"tags": [ | |
], | |
"google_analytics_domains": [ | |
], | |
"google_analytics_campaign": "...", | |
"metadata": [ | |
], | |
"recipient_metadata": [ | |
], | |
"attachments": [ | |
] | |
}, | |
"async": false | |
}'; | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, $uri); | |
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true ); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true ); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); | |
curl_setopt($ch, CURLOPT_POST, true); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, $postString); | |
$result = curl_exec($ch); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment