function wp_mail_bank_configure($phpmailer) { global $wpdb; $data = $wpdb->get_row("SELECT * FROM " . wp_mail_bank()); $mail_type = $data->mailer_type; $phpmailer->Mailer = $data->mailer_type == 0 ? "smtp" : "mail"; $phpmailer->FromName = stripslashes(htmlspecialchars_decode($data->from_name, ENT_QUOTES)); $phpmailer->From = $data->from_email; $phpmailer->Sender = $data->return_path == 0 ? $data->return_email : $data->from_email; $phpmailer->WordWrap = $data->word_wrap; $phpmailer->SMTPOptions = array('ssl' => array('verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true)); if ($data->mailer_type == 0) { switch ($data->encryption) { case 0: $phpmailer->SMTPSecure = ""; break; case 1: $phpmailer->SMTPSecure = "ssl"; break; case 2: $phpmailer->SMTPSecure = "tls"; break; } $phpmailer->Host = $data->smtp_host; $phpmailer->Port = $data->smtp_port; if ($data->smtp_keep_alive == 1) { $phpmailer->SMTPKeepAlive = TRUE; } if ($data->authentication == 1) { $phpmailer->SMTPAuth = TRUE; $phpmailer->Username = $data->smtp_username; $phpmailer->Password = $data->smtp_password; } } }
function create_table_mail_detail() { $sql = "CREATE TABLE " . wp_mail_bank() . " (\r\n\t\t\t\tid INTEGER(10) NOT NULL AUTO_INCREMENT,\r\n\t\t\t\tfrom_name VARCHAR(100),\r\n\t\t\t\tfrom_email VARCHAR(100),\r\n\t\t\t\tmailer_type INTEGER(1),\r\n\t\t\t\treturn_path INTEGER(1),\r\n\t\t\t\treturn_email VARCHAR(100),\r\n\t\t\t\tsmtp_host VARCHAR(100),\r\n\t\t\t\tsmtp_port INTEGER(5),\r\n\t\t\t\tword_wrap INTEGER(10),\r\n\t\t\t\tencryption INTEGER(1),\r\n\t\t\t\tsmtp_keep_alive INTEGER(5),\r\n\t\t\t\tauthentication INTEGER(1),\r\n\t\t\t\tsmtp_username VARCHAR(100),\r\n\t\t\t\tsmtp_password VARCHAR(100),\r\n\t\t\t\tPRIMARY KEY (id)\r\n\t\t\t\t) DEFAULT CHARSET=utf8 COLLATE utf8_general_ci"; dbDelta($sql); }
$email_setup["return_email"] = esc_attr($_REQUEST["ux_return_email"]); $email_setup["word_wrap"] = intval($_REQUEST["ux_word_wrap"]); $email_setup["smtp_host"] = esc_attr($_REQUEST["ux_smtp_host"]); $email_setup["smtp_port"] = esc_attr($_REQUEST["ux_smtp_port"]); $email_setup["encryption"] = intval($_REQUEST["ux_rdl_encrption"]); $email_setup["smtp_keep_alive"] = intval($_REQUEST["ux_rdl_smtp_alive"]); $email_setup["authentication"] = intval($_REQUEST["ux_rdl_authentication_bank"]); $email_setup["smtp_username"] = esc_attr($_REQUEST["ux_txt_username"]); $email_setup["smtp_password"] = htmlspecialchars_decode(esc_attr($_REQUEST["password"])); $count_direction = $wpdb->get_var("SELECT count(id) FROM " . wp_mail_bank()); if ($count_direction == 0) { $insert->insert_data(wp_mail_bank(), $email_setup); } else { $where = array(); $where["id"] = 1; $insert->update_data(wp_mail_bank(), $email_setup, $where); } die; } elseif ($_REQUEST["param"] == "send_mail") { global $phpmailer; $logs = array(); if (!is_object($phpmailer) || !is_a($phpmailer, 'PHPMailer')) { require_once ABSPATH . WPINC . '/class-phpmailer.php'; require_once ABSPATH . WPINC . '/class-smtp.php'; $phpmailer = new PHPMailer(true); } $phpmailer->SMTPDebug = true; ob_start(); $to = esc_attr($_REQUEST["ux_email_to"]); $subject = esc_attr($_REQUEST["ux_email_subject"]); $message = stripslashes($_REQUEST["message"]);
switch ($role) { case "administrator": $user_role_permission = "manage_options"; break; case "editor": $user_role_permission = "publish_pages"; break; case "author": $user_role_permission = "publish_posts"; break; } if (!current_user_can($user_role_permission)) { return; } else { $email_data = $wpdb->get_row("SELECT * FROM " . wp_mail_bank()); $admin_email = get_option('admin_email'); ?> <form id="ux_frm_email" class="layout-form" style="max-width:1000px;"> <div id="message" class="top-right message" style="display: none;"> <div class="message-notification"></div> <div class="message-notification ui-corner-all growl-success" > <div onclick="message_close();" id="close-message" class="message-close">x</div> <div class="message-header"><?php _e("Success!", mail_bank); ?> </div> <div class="message-message"><?php _e("Settings has been successfully saved.", mail_bank); ?> </div>