doukuang6795 2015-10-26 20:39
浏览 73

无法让SendGrid PHP在我的WebApp中工作,甚至无法正确地(可能)与我的应用程序集成(导致500内部服务器错误)

I have ready order confirm script in HTML/PHP in Asp.net project (receipt.php) ready to mail to customer, but strangely can't manage to send it with Sendgrid no matter how hard I've tried.

<?php
$_SESSION['data'] = $_POST['data'];
$data = $_SESSION['data']; 
$email = $data[email];
$first_name = $data[shipping_address][name];
$address1 = $data[shipping_address][address_line_1];
$zip = $data[shipping_address][zip];
$city = $data[shipping_address][city];


$messageaddr = "
<html>
    <head>
        <title>
                               <td align='left' valign='bottom' width='350'>
                                <font face='Verdana, Geneva, sans-serif' size='2'></font>
                            </td>
                            <td align='left' valign='bottom' width='250'>
                            </td>
                        </tr>
                    </tbody></table>
                    <hr>
                    <table width='100%' cellpadding='0' cellspacing='0'>
                        <tbody><tr>
                            <td valign='top'>
                                <p><font face='Verdana, Geneva, sans-serif' size='4'>Laskutusosoite</font></p>
                                <font face='Verdana, Geneva, sans-serif' size='2'>
                                    $first_name<br>
                                    <br>
                                    $address1<br>
                                    $zip $city<br>
                                    <br>
                                    Suomi<br>
                                    <a href='mailto: $email' target='_blank'>$email</a><br>
<div id=':nj' class='a3s' style='overflow: hidden;'><div class='adM'>
$namearr = $_POST["name"];
$imagearr = $_POST["image"];
$pricearr = $_POST["price"];
$quantityarr = $_POST["quantity"];
$totalcostarr = $_POST["totalcost"];

ob_start();

 for ($x = 0; $x <= $lenth-1; $x++) {
    echo "<td align='left' style='padding:10px 10px 10px 0;border-bottom:1px solid #d7d7d7;vertical-align:top'>

                               <td align='right' style='padding:10px 0;border-bottom:1px solid #d7d7d7;vertical-align:top'><p><font face='Tahoma, arial, sans-serif' size='2'>$pricearr[$x]<br></font></p></td>
                                <td align='right' style='padding:10px 0;border-bottom:1px solid #d7d7d7;vertical-align:top'><p><font face='Tahoma, arial, sans-serif' size='2'>$quantityarr[$x]<br></font></p></td>
                                <td align='right' style='padding:10px 0;border-bottom:1px solid #d7d7d7;vertical-align:top'><p><font face='Tahoma, arial, sans-serif' size='2'>$totalcostarr[$x]<br></font></p></td>
                            </tr><tr>

$products = ob_get_clean();
ob_end_clean();

$footermessage = "
                       </tr></tbody>
                        <tfoot>
                            <tr>
                                <td style='padding:10px 0;border-bottom:2px solid #000'>&nbsp;</td>
                                <td style='padding:10px 0;border-bottom:2px solid #000' align='right'><font face='Tahoma, arial, sans-serif' size='2'>Välisumma<br>Toimitus</font></td>
                                <td style='padding:10px 0;border-bottom:2px solid #000'>&nbsp;</td>
                                <td style='padding:10px 0;border-bottom:2px solid #000' align='right'><font face='Tahoma, arial, sans-serif' size='2'>$subtotal<br>$shipping</font></td>
                            </tr>
                            <tr>
                                                              style='padding:10px 0;border-bottom:1px solid #000'>&nbsp;</td>                                
    </tr>
</tbody>    
<tfoot>
";
$message = $messageaddr . ' ' . $products . ' ' . $footermessage; 
return $message;                
?>

I've tried with GitHub instructs https://github.com/sendgrid/sendgrid-php, added necessary 'requires' to composer.json-file etc., what else do I need on top these, except of course user and password?

No more lucky with instructions of Azure https://azure.microsoft.com/en-us/documentation/articles/store-sendgrid-php-how-to-send-email/ ,I have composer, but no matter is it with SMTP API or Web Api, with Swift ends for same 500 server error, can't even managed to install for Web Api with Curl.

Sendgrid wizard https://sendgrid.com/docs/Utilities/code_workshop.html provided the whole lib/vendor folders and several probable essential files, but don't know, should the whole package include my Web api project or just necessary (sendgrid-php, autoload.php etc.) and to which directory they needed to copy?

How on earth they call sendgrid easy(????) or maybe I still miss something essential? Would be grateful, if somebody could give yet another instructions for dummy , prefer with PHP-script, but with ASP.NET C# too, if that could be apply for this equally.

main.js posting the receipt;

            var xhr = $.post('receipt.php', { data: data, name: name, image: image, price: price, quantity: quantity, totalcost: totalcost, totals: basketCollection.totals , length: basketCollection.length }, function (data) {
                var data_from_ajax = data;
                console.log(data_from_ajax);
            });
  • 写回答

1条回答 默认 最新

  • duancenxiao0482 2015-10-28 18:37
    关注

    After an hours of trying got it work! Main PHP-script was in a wrong directory related to the others in package.

    Just sending dublicate emails mostly. Could it even cause from Sendgrid or just a local operator problem?

    评论

报告相同问题?

悬赏问题

  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥15 绘制多分类任务的roc曲线时只画出了一类的roc,其它的auc显示为nan
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?