$data_string = json_decode(json_encode('{
"SaveToSentItems": "false",
"Message": {
"Subject": "'.$_POST['subject'].'",
"Importance": "High",
"Body": {
"ContentType": "HTML",
"Content": "'.addslashes($_POST['message']).'"
},
"ToRecipients": [
{
"EmailAddress": {
"Name":"'.$_POST['displayName'].'",
"Address": "'.$_POST['mail'].'"
}
}
]
}
}'),TRUE);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://outlook.office365.com/api/v1.0/me/sendmail");
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, $_POST['auth']);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_HEADER , true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json'
)
);
$result = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);