Отправить письмо через веб-приложение Azure через sendgrid - PullRequest
0 голосов
/ 21 ноября 2018

У меня есть веб-сайт, работающий на Azure, и я могу получать электронные письма.У меня установлена ​​учетная запись Sendgrid в моей системе Azure.Но у меня есть форма подписчика, мне нужно отправить благодарственное письмо подписчикам.Я не могу понять, как получить данные формы в мой файл php sendgrid.Пожалуйста, помогите мне в получении данных формы в php.

My action_page.php file
    <?php

$url = 'https://api.sendgrid.com/';
$user = 'username';
$pass = 'pwd'; 

$params = array(
    'api_user'  => $user,
    'api_key'   => $pass,
    'to'        => 'subscriber email',
    'subject'   => 'testing from curl',
    'html'      => 'testing body',
    'text'      => 'testing body',
    'from'      => 'company email',
  );


$request =  $url.'api/mail.send.json';

// Generate curl request
$session = curl_init($request);
// Tell curl to use HTTP POST
curl_setopt ($session, CURLOPT_POST, true);
// Tell curl that this is the body of the POST
curl_setopt ($session, CURLOPT_POSTFIELDS, $params);
// Tell curl not to return headers, but do return the response
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);

// obtain response
$response = curl_exec($session);
curl_close($session);

// print everything out
print_r($response);

?>

HTML-файл

<form action="action_page.php" method="POST" >

  <input type="text" id="fname" name="firstname" placeholder="First Name">

  <br>

  <input type="text" id="lname" name="lastname" placeholder="Last Name">

  <br>

  <input type="email" id="email" name="email" placeholder="Email">

  <br>

  <label>

  <input type="checkbox" checked="checked" name="remember" value="Yes" style="margin-bottom:15px">

  <span style="color:#f08615"> Sign up for latest news</span>

    </label>

    <br>



<input type="submit" name="subscribe" value="Subscribe">

</form>
...