WordPress will not send two different emails to two different email addresses

I am working on a web app and I am having difficulty getting WordPress to send two different emails to two different email addresses. I am calling wp_mail twice. The first $message always sends, but the second $confirmation will not send. It doesn’t matter if I use a variable to define the “to” or hard code in an email, the $confirmation never sends. I’ve tried concatenating single quotes to the email just to ensure proper formatting, but nothing.

Does anyone have any knowledge as to how you properly send two different emails using wp_mail?

Read More

I will post the snippet of the code I am using for the message. I am using a switch to take customers through an ordering process.

I am fairly new to this, so it’s possible I’m missing something with the syntax, but any help would be so so appreciated.

    case 5: // Confirmation
    /*if (!isset($order->dumpster_purpose)) {
        wp_redirect('/order');
        exit;
    }*/

    $message = '' . "
ORDER TYPE
------------------------------------------------------------
" . ($order->type == ORDER_TYPE_TEMP ? 'Temporary Rental' : 'Permanent Scheduled Pickup') . "


DUMPSTER INFORMATION
------------------------------------------------------------
Dumpster: {$order->dumpster}
Dumpster Amount: {$order->dumpster_amount}
Purpose for Dumpster: {$order->dumpster_purpose}
Needed for: {$order->dumpster_use}
Schedule Type: {$order->schedule_type}
Disposing of:
";
    foreach($order->disposing_materials as $material) {
        $message.= " - {$material}rn";
    }

    $message.= "

DELIVERY INFORMATION
------------------------------------------------------------
Name: {$order->full_name}
";
    if (!empty($order->business_name)) $message.= "Business Name: {$order->business_name}rn";
    $message.= "Phone: {$order->phone}
Email: {$order->email}
";
    $message.= "
Address:
{$order->d_address}
{$order->d_city}, {$order->d_state} {$order->d_zip}
";
    $message.= "
Delivery Date: {$order->d_date}
";
    if (!empty($order->instructions)) $message.= "rnDelivery Instructions:rn{$order->instructions}rn";
    if (FALSE && $order->type == ORDER_TYPE_TEMP) {
        $message.= "

BILLING INFORMATION
------------------------------------------------------------
Address:
{$order->b_address}
{$order->b_city}, {$order->b_state} {$order->b_zip}

Card Info:
{$order->card_type}
{$order->card_number}
{$order->card_code}
{$order->card_exp_month}/{$order->card_exp_year}
";
    }

    wp_mail(ORDER_RECIPIENTS, $order->type == ORDER_TYPE_TEMP ? 'Online Dumpster Order' : 'Online Dumpster Quote Request', $message);

        $confirmation = '' . "
ORDER TYPE
------------------------------------------------------------
" . ($order->type == ORDER_TYPE_TEMP ? 'Temporary Rental' : 'Permanent Scheduled Pickup') . "


DUMPSTER INFORMATION
------------------------------------------------------------
Dumpster: {$order->dumpster}
Dumpster Amount: {$order->dumpster_amount}
Purpose for Dumpster: {$order->dumpster_purpose}
Needed for: {$order->dumpster_use}
Schedule Type: {$order->schedule_type}
Disposing of:
";
$email = $order->email;
    wp_mail($email, $order->type == ORDER_TYPE_TEMP ? 'Online Dumpster Order' : 'Online Dumpster Quote Request', $confirmation);
    //session_destroy();
    break;
}

Related posts

Leave a Reply