<td style="padding-left: 20px; text-align: left;"> <span style="font-size: 18px; line-height: 1.44; color: #8B9299; display: block;">' . $userData["playlist"][$key]["artist_name"] . '</span> <span style="font-size: 18px; line-height: 1.44; color: #233332; display: block; padding-bottom: 5px;">' . $userData["playlist"][$key]["track_name"] . '</span> <a href="https://play.spotify.com/track/' . $userData["playlist"][$key]["id"] . '"> <img src="http://res.cloudinary.com/dtavhihxu/image/upload/v1466015803/play-with_hmyqe6.png" width="130"> </a> </td> </tr> </table>'; } else { $notice = "Did not submit a track :("; } $events_table .= "</table>"; echo "<p>" . $subject . "</p>"; echo "<p>" . $subject_guest . "</p>"; echo $events_table; echo $notice; echo $userData["email"]; if (STOP_SENDING) { } else { $data = array("id" => 1, "to" => $userData["email"], "attr" => array("FNAME" => $userData["guests"][$key]["fname"], "LNAME" => $userData["guests"][$key]["lname"], "EVENT_LOOP" => $events_table, "TRACK" => $notice, "DATE" => date('F j, Y, g:i a', $guest["date_created"] / 1000), "NOTICE" => "Amazing!", "LINK" => "http://app.cnftti.com/", "SUBJECT" => $subject, "COVER_IMAGE" => $cover_image)); $data_guest = array("id" => 6, "to" => $userData["guests"][$key]["email"], "attr" => array("FNAME" => $userData["guests"][$key]["fname"], "EVENT_LOOP" => $events_table, "TRACK" => $notice, "DATE" => date('F j, Y, g:i a', $guest["date_created"] / 1000), "NOTICE" => "Amazing!", "LINK" => "http://app.cnftti.com/#/page/" . $userData["username"] . "/" . $key, "SUBJECT" => $subject_guest, "COVER_IMAGE" => $cover_image)); var_dump($mailin->send_transactional_template($data)); var_dump($mailin->send_transactional_template($data_guest)); } } } } } } // print_r($userData);
/** * Send mail * @params (type, to_email, to_info, list_id) */ function send_email($type, $to_email, $code, $list_id, $template_id = '-1', $attributes = null) { $mailin = new Mailin(SIB_Manager::sendinblue_api_url, SIB_Manager::$access_key); // set subject info if ($type == 'confirm') { $subject = __('Subscription confirmed', 'sib_lang'); } elseif ($type == "double-optin") { $subject = __('Please confirm subscription', 'sib_lang'); } // get sender info if (self::$account_email != '') { $sender_name = trim(self::$account_user_name); $sender_email = trim(self::$account_email); } else { $sender_email = trim(get_bloginfo('admin_email')); $sender_name = trim(get_bloginfo('name')); } if ($sender_email == '') { $sender_email = __('*****@*****.**', 'sib_lang'); $sender_name = __('SendinBlue', 'sib_lang'); } $template_contents = self::get_email_template($type); $html_content = $template_contents['html_content']; $text_content = $template_contents['text_content']; $transactional_tags = 'Wordpress Mailin'; // get template html and text if (intval($template_id) > 0) { $data = array('id' => $template_id); $response = $mailin->get_campaign_v2($data); if ($response['code'] == 'success') { $html_content = $response['data'][0]['html_content']; if (trim($response['data'][0]['subject']) != '') { $subject = trim($response['data'][0]['subject']); } if ($response['data'][0]['from_name'] != '[DEFAULT_FROM_NAME]' && $response['data'][0]['from_email'] != '[DEFAULT_FROM_EMAIL]' && $response['data'][0]['from_email'] != '') { $sender_name = $response['data'][0]['from_name']; $sender_email = $response['data'][0]['from_email']; } $transactional_tags = $response['data'][0]['campaign_name']; } } // send mail $to = array($to_email => ''); $from = array($sender_email, $sender_name); $null_array = array(); $site_domain = str_replace('https://', '', home_url()); $site_domain = str_replace('http://', '', $site_domain); $html_content = str_replace('{title}', $subject, $html_content); $html_content = str_replace('https://[DOUBLEOPTIN]', '{subscribe_url}', $html_content); $html_content = str_replace('http://[DOUBLEOPTIN]', '{subscribe_url}', $html_content); $html_content = str_replace('[DOUBLEOPTIN]', '{subscribe_url}', $html_content); $html_content = str_replace('{site_domain}', $site_domain, $html_content); $html_content = str_replace('{unsubscribe_url}', add_query_arg(array('sib_action' => 'unsubscribe', 'code' => $code, 'li' => $list_id), home_url()), $html_content); $html_content = str_replace('{subscribe_url}', add_query_arg(array('sib_action' => 'subscribe', 'code' => $code, 'li' => $list_id), home_url()), $html_content); $text_content = str_replace('{site_domain}', home_url(), $text_content); if (SIB_Manager::$activate_email == 'yes') { if (intval($template_id) > 0 && is_array($attributes) && $type == "confirm") { $attrs = array_merge($attributes, array('EMAIL' => $to_email)); $data = array("id" => intval($template_id), "to" => $to_email, "cc" => "", "bcc" => "", "attr" => $attrs, "attachment_url" => "", "attachment" => array(), "headers" => array("Content-Type" => "text/html;charset=iso-8859-1", "X-Mailin-tag" => $transactional_tags)); $mailin->send_transactional_template($data); } else { $headers = array("Content-Type" => "text/html;charset=iso-8859-1", "X-Mailin-tag" => $transactional_tags); $data = array("to" => $to, "cc" => array(), "bcc" => array(), "from" => $from, "replyto" => array(), "subject" => $subject, "text" => $text_content, "html" => $html_content, "attachment" => array(), "headers" => $headers, "inline_image" => array()); $mailin->send_email($data); } } else { $headers[] = 'Content-Type: text/html; charset=UTF-8'; $headers[] = "From: {$sender_name} <{$sender_email}>"; @wp_mail($to_email, $subject, $html_content, $headers); } }