dpowhyh70416 2018-11-21 20:54
浏览 90

通过sendgrid通过azure web app发送电子邮件

I have a website running on azure and I am able to receive emails. I have Sendgrid account installed in my azure. But I have subscriber form, I need to send thank you email to subscribers. I am not able to figure out how to get form data into my php sendgrid file. Please help me out in getting form data into 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 file

<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>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥65 永磁型步进电机PID算法
    • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
    • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
    • ¥15 如何处理复杂数据表格的除法运算
    • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
    • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
    • ¥15 latex怎么处理论文引理引用参考文献
    • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
    • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
    • ¥15 乘性高斯噪声在深度学习网络中的应用