Created
December 25, 2015 13:59
-
-
Save hunnycode/6fe9a7792096fd38c76a to your computer and use it in GitHub Desktop.
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 | |
$to = $_POST['email']; | |
$from = "送信元メールアドレス"; | |
$subject = $_POST['subject']; | |
$body = $_POST['body']; | |
$url = 'https://api.sendgrid.com/'; | |
$user = 'SendGrid username'; | |
$pass = 'SendGrid Password'; | |
$params = array( | |
'api_user' => $user, | |
'api_key' => $pass, | |
'to' => $to, | |
'subject' => $subject, | |
'text' => $body, | |
'from' => $from, | |
); | |
$request = $url.'api/mail.send.json'; | |
$session = curl_init($request); | |
curl_setopt ($session, CURLOPT_POST, true); | |
curl_setopt ($session, CURLOPT_POSTFIELDS, $params); | |
curl_setopt($session, CURLOPT_HEADER, false); | |
curl_setopt($session, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2); | |
curl_setopt($session, CURLOPT_RETURNTRANSFER, true); | |
$response = curl_exec($session); | |
curl_close($session); | |
print_r($response); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment