Skip to content

Instantly share code, notes, and snippets.

@hunnycode
Created December 25, 2015 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hunnycode/6fe9a7792096fd38c76a to your computer and use it in GitHub Desktop.
Save hunnycode/6fe9a7792096fd38c76a to your computer and use it in GitHub Desktop.
<?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