Created
May 6, 2020 23:26
-
-
Save gmotzespina/cdfe848bf32d2ed4a56fd8d96f17d8aa to your computer and use it in GitHub Desktop.
PHP and mailgun configuration
This file contains hidden or 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 | |
| define('MAILGUN_URL', 'https://api.mailgun.net/v3/YOUR_URL'); | |
| define('MAILGUN_KEY', 'MAILGUN_KEY'); | |
| $mail = $_POST; | |
| $name = $mail['name']; | |
| $from = $mail['email']; | |
| if(empty($from) || empty($name)) { | |
| print('false'); | |
| return false; | |
| } | |
| $message = ' | |
| Compañía: '.$mail['company'].' | |
| Nombre de contacto: '.$name.' | |
| Ciudad: '.$mail['city'].' | |
| Teléfono: '.$mail['phone'].' | |
| '.$mail['message']; | |
| $to = "gmotzespina@icloud.com"; | |
| $subject = "Contacto de Powerjet"; | |
| $array_data = array( | |
| 'from'=> 'Visitante de Powerjet' .'<'.$from.'>', | |
| 'to'=> $to, | |
| 'subject'=> $subject, | |
| 'text'=> $message, | |
| 'o:tracking'=>'yes', | |
| 'o:tracking-clicks'=>'yes', | |
| 'o:tracking-opens'=>'yes' | |
| ); | |
| $session = curl_init(MAILGUN_URL.'/messages'); | |
| curl_setopt($session, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); | |
| curl_setopt($session, CURLOPT_USERPWD, 'api:'.MAILGUN_KEY); | |
| curl_setopt($session, CURLOPT_POST, true); | |
| curl_setopt($session, CURLOPT_POSTFIELDS, $array_data); | |
| curl_setopt($session, CURLOPT_HEADER, false); | |
| curl_setopt($session, CURLOPT_ENCODING, 'UTF-8'); | |
| curl_setopt($session, CURLOPT_RETURNTRANSFER, true); | |
| curl_setopt($session, CURLOPT_SSL_VERIFYPEER, false); | |
| $response = curl_exec($session); | |
| curl_close($session); | |
| print($response); | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment