addCC() public method

See also: addTo()
public addCC ( $cc )
示例#1
0
 public function sendmail()
 {
     $this->load->library('form_validation');
     $this->load->model('EmailModel');
     $this->load->model('UserModel');
     $name = $this->input->post('name');
     $email = $this->input->post('email');
     $subject = $this->input->post('subject');
     $msg = $this->input->post('msg');
     $adminUsers = $this->UserModel->getAdminUsers();
     foreach ($adminUsers as $userAdmin) {
         $receiverAdminId[] = $userAdmin->id;
         $receiverAdminEmail[] = $userAdmin->email;
     }
     $emailId = $this->EmailModel->insertEmails('Success', $receiverAdminId);
     $link = '<a href="' . base_url(ADMIN_PATH . "mail/read_mail/" . $emailId) . '" target="_blank">here</a>';
     $emailMessage = "You've received email from " . $name . ". Click " . $link . " to view the message.";
     $this->load->library('SimpleEmailService');
     $ses = new SimpleEmailService('AKIAISEC5PBG2F54VL4A', 'ZhRYSpKdUMLRrxPwy878UN+pJmnllAocdcYRpJwZ');
     $ses->enableVerifyPeer(false);
     //print_r($ses->verifyEmailAddress('*****@*****.**'));
     $m = new SimpleEmailServiceMessage();
     $m->addTo(EMAILSENDER);
     $m->addCC($receiverAdminEmail);
     $m->setFrom($email . '<' . EMAILSENDER . '>');
     $m->setSubject($subject);
     $message = $emailMessage;
     $m->setMessageFromString('', $message);
     if ($ses->sendEmail($m)) {
         if ($this->uri->segment(1) == 'Contact' || $this->uri->segment(1) == 'contact') {
             $this->session->set_flashdata("su_message", "Email Sent Successfully");
             redirect("contact");
         } else {
             echo "<script>alert('Email Sent Successfully');window.history.back();</script>";
         }
     }
 }
示例#2
0
文件: wp-ses.php 项目: amprog/wp-ses
function wpses_mail($to, $subject, $message, $headers = '', $attachments = '')
{
    global $SES;
    global $wpses_options;
    global $wp_better_emails;
    // headers can be sent as array, too. convert them to string to avoid further complications.
    if (is_array($headers)) {
        $headers = implode("\r\n", $headers);
    }
    if (is_array($to)) {
        $to = implode(",", $to);
    }
    extract(apply_filters('wp_mail', compact('to', 'subject', 'message', 'headers')));
    wpses_log('wpses_mail ' . $to . "\t" . $headers);
    wpses_check_SES();
    if (isset($wp_better_emails)) {
        // From wpbe plugin, not efficient nor elegant - Will do better next time.
        // Could just call the php filter on a adhoc object, to be less dependant on the implementation of wpbe code.
        $txt = wp_specialchars_decode($message, ENT_QUOTES);
        $txt = $wp_better_emails->set_email_template($txt, 'plaintext_template');
        $txt = apply_filters('wpbe_plaintext_body', $wp_better_emails->template_vars_replacement($txt));
        /** HTML ******************************************************* */
        $html = $wp_better_emails->esc_textlinks($message);
        $html = nl2br(make_clickable($html));
        $html = $wp_better_emails->set_email_template($html);
        $html = apply_filters('wpbe_html_body', $wp_better_emails->template_vars_replacement($html));
    } else {
        $message = preg_replace('/<(http:.*)>/', '$1', $message);
        $message = preg_replace('/<(https:.*)>/', '$1', $message);
        // bad hack - handle httpS as well.
        $html = $message;
        $txt = strip_tags($html);
        if (strlen($html) == strlen($txt)) {
            $html = '';
            // que msg text
        }
        // no html entity in txt.
        $txt = html_entity_decode($txt, ENT_NOQUOTES, 'UTF-8');
    }
    // TODO: option pour que TXT si msg html, ou les deux comme ici par défaut.
    $m = new SimpleEmailServiceMessage();
    // To: may contain comma separated emails. If so, explode and add them all.
    // what to do if more than 50 ? (SES limit)
    if (preg_match('/,/im', $to)) {
        $to = explode(',', $to);
        foreach ($to as $toline) {
            $m->addTo($toline);
        }
    } else {
        $m->addTo($to);
    }
    $m->setReturnPath($wpses_options['return_path']);
    $from = $wpses_options['from_name'] . ' <' . $wpses_options['from_email'] . '>';
    if ('' != $wpses_options['reply_to']) {
        if ('headers' == strtolower($wpses_options['reply_to'])) {
            // extract replyto from headers
            $rto = array();
            //if (preg_match('/^Reply-To: ([a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4})\b/imsU', $headers, $rto)) {
            //if (preg_match('/^Reply-To: (.*)\b/imsU', $headers, $rto)) {
            if (preg_match('/^Reply-To: (.*)/im', $headers, $rto)) {
                // does only support one email for now.
                $m->addReplyTo($rto[1]);
            }
            if (preg_match('/^From: (.*)/im', $headers, $rto)) {
                // Uses "From:" header - was /isU which broke things, see https://wordpress.org/support/topic/gravity-forms-18205-latest-contact-form-7-403-latest-not-working
                $from = $rto[1];
            }
            // Handle multiple cc and bcc: from headers too ? Guess so... TODO
            if ('' != $headers) {
                $headers = str_replace("\r\n", "\n", $headers);
                $lines = explode("\n", $headers);
                foreach ($lines as $line) {
                    if (preg_match('/^cc: (.*)/im', $line, $cc)) {
                        $m->addCC($cc[1]);
                    }
                    if (preg_match('/^Bcc: (.*)/im', $line, $Bcc)) {
                        $m->addBCC($Bcc[1]);
                    }
                }
            }
            // Test : use full headers if provided
            //$m->addCustomHeader($headers);
        } else {
            $m->addReplyTo($wpses_options['reply_to']);
        }
    }
    $m->setFrom($from);
    $m->setSubject($subject);
    if ($html == '') {
        // que texte
        $m->setMessageFromString($txt);
    } else {
        $m->setMessageFromString($txt, $html);
    }
    // Attachments
    if ('' != $attachments) {
        if (!is_array($attachments)) {
            $attachments = explode("\n", $attachments);
        }
        // Now we got an array
        foreach ($attachments as $afile) {
            $m->addAttachmentFromFile(basename($afile), $afile);
        }
    }
    set_error_handler('wpses_error_handler');
    $res = $SES->sendEmail($m);
    restore_error_handler();
    // Call custom Hook
    do_action('wpses_mailsent', $to, $subject, $message, $headers, $attachments);
    if (is_array($res)) {
        wpses_log('SES id=' . $res['MessageId']);
        return $res['MessageId'];
    } else {
        return NULL;
    }
}
示例#3
0
 function supportEmail()
 {
     $clientOwner = array('Client', 'Owner');
     $result = array_intersect($clientOwner, $this->session->userdata(ROLES));
     if ($result) {
         $brokerId = $this->UserModel->getBrokerFromClientid($this->session->userdata(USER_ID));
         $brokerIdArray = array($brokerId);
         $brokerEmail[] = $this->UserModel->getEmailAddress($brokerId);
     }
     $adminUsers = $this->UserModel->getAdminUsers();
     foreach ($adminUsers as $userAdmin) {
         $receiverAdminId[] = $userAdmin->id;
         $receiverAdminEmail[] = $userAdmin->email;
     }
     if ($brokerIdArray) {
         $receiverId = array_unique(array_merge($receiverAdminId, $brokerIdArray));
         $receiverEmail = array_unique(array_merge($receiverAdminEmail, $brokerEmail));
     } else {
         $receiverId = $receiverAdminId;
         $receiverEmail = $receiverAdminEmail;
     }
     $emailId = $this->EmailModel->insertEmails('Success', $receiverId);
     $link = '<a href="' . base_url(ADMIN_PATH . "mail/read_mail/" . $emailId) . '" target="_blank">here</a>';
     $emailMessage = "You've received email from " . $this->session->userdata(NAME) . ". Click " . $link . " to view the message.";
     $subject = $this->input->post('subject');
     $message = $emailMessage;
     $this->load->library('SimpleEmailService');
     $ses = new SimpleEmailService('AKIAISEC5PBG2F54VL4A', 'ZhRYSpKdUMLRrxPwy878UN+pJmnllAocdcYRpJwZ');
     $ses->enableVerifyPeer(false);
     $m = new SimpleEmailServiceMessage();
     $m->addTo(EMAILSENDER);
     $m->addCC($receiverEmail);
     $m->setFrom($this->name . ' via Credit University' . '<' . EMAILSENDER . '>');
     $m->setSubject($subject);
     $msg = $message;
     $m->setMessageFromString('', $msg);
     $ses->sendEmail($m);
     $this->session->set_flashdata("supportMessage", "Support & Suggestion email has been sent successfully.");
     redirect(ADMIN_PATH);
 }