Mandrill文件给出500错误但仍执行功能

时间:2014-08-19 08:56:12

标签: javascript php mandrill

我有一个mandrill PHP SDK用于执行从用户到管理员的交易电子邮件。

我面临的问题是提交表单,mandrill文件提供错误500,但仍然执行该功能,管理员仍然收到电子邮件。

mandrill PHP文件:

<?php
require('./mandrill/Mandrill.php');
$html = 'Hey, <br>'.'You got mail from '.$_GET['Name'].' email: '.$_GET['Email'].' phone: '.$_GET['Phone'].'.<br>Their message is, '.$_GET['message'];
try {
    $mandrill = new Mandrill('KEY_GOES_HERE');
    $message = array(
        'html' => $html,
        'subject' => 'User Message',
        'from_email' => 'random@email.com',
        'from_name' => 'random_name',
        'to' => array(
            array(
                'email' => 'to_random@email.com',
            )
        ),
        'headers' => array('Reply-To' => 'none'),
        'important' => false,
        'track_opens' => null,
        'track_clicks' => null,
        'auto_text' => null,
        'auto_html' => null,
        'inline_css' => null,
        'url_strip_qs' => null,
        'preserve_recipients' => null,
        'view_content_link' => null,
        'bcc_address' => 'message.bcc_address@example.com',
        'tracking_domain' => null,
        'signing_domain' => null,
        'return_path_domain' => null,
        'merge' => true,
        'global_merge_vars' => array(
            array(
                'name' => 'merge1',
                'content' => 'merge1 content'
            )
        ),
    );
    $async = false;


    $result = $mandrill->messages->send($message, $async, $ip_pool, $send_at);
    print_r($result);
    /*
    Array
    (
        [0] => Array
            (
                [email] => recipient.email@example.com
                [status] => sent
                [reject_reason] => hard-bounce
                [_id] => abc123abc123abc123abc123abc123
            )

    )
    */
} catch(Mandrill_Error $e) {
    // Mandrill errors are thrown as exceptions
    echo 'A mandrill error occurred: ' . get_class($e) . ' - ' . $e->getMessage();
    // A mandrill error occurred: Mandrill_Unknown_Subaccount - No subaccount exists with the id 'customer-123'
    throw $e;
}
?>

发送序列化表单的JavaScript如下:

$("#submit").on("click", function() {
    var e = $("#modal-contact-form").serialize();
    if (!n()) return false;
    $.ajax({
        type: 'GET',
        url: "./mandrill_mailer.php",
        data: e,
        success: function() {
            alert("Got it, thanks! We'll be in touch soon!");
            $("#modal-contact-form").find("input[type=text], textarea").val("")
        }
    });
    return false
});

这个特殊问题仅在GoDaddy主机上面临,而它在我的localhost上完美运行。我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

我偶尔会看到500个invalid_key错误错误 - 例如,如果您有一个受限制的API密钥。我不希望电子邮件仍然发送。

您检查了API Logs吗?