-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsend.php
46 lines (33 loc) · 1.16 KB
/
send.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
extract($_POST);
$nombre = $_POST['name'] ;
$remitente = $_POST['email'] ;
$lenguaje = $_POST['lang'];
$asunto = "Mensaje de HomeworkCode";
$nivel = $_POST['level'];
$mensaje = $_POST['msj'];
//set POST variables
$url = 'https://api.mailgun.net/v3/sandboxc9c4b7ab94f84710adb8e847cff7ac43.mailgun.org/messages';
$fields = "";
$fields = array(
'from' => urlencode($remitente),
'to' => urlencode('[email protected]' ),
'subject' => urlencode($asunto),
'text' => urlencode("Nombre:" .$name ."\nLenguaje :" .$lenguaje."\nNivel : ".$nivel. "\n Desarrollo:\n\n" . $mensaje ."</p>")
);
//url-ify the data for the POST
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string, '&');
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_USERPWD,'api:key-d43fcd11e3fa56d5ccc0d8f4e241aff4' );
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);
header('Location: index.php');
?>