コード例 #1
0
 public function sendEmailViaAmazon($title, $body, $args)
 {
     $mail_mime = new Mail_mime();
     $mail_mime->setHTMLBody($body);
     $body = $mail_mime->get();
     $headers = $mail_mime->txtHeaders(array('From' => 'Comnovo Web Service<' . SERVICE_EMAIL . '>', 'Reply-To' => SERVICE_EMAIL, 'Subject' => "{$title}"));
     $message = $headers . "\r\n" . $body;
     $sendResult = $this->emailConnetHandler->send_raw_email(array('Data' => base64_encode($message)), array('Destinations' => $args['user_email']));
     if ($sendResult->isOK()) {
         print "Mail sent; message id is " . (string) $sendResult->body->SendRawEmailResult->MessageId . "\n";
     } else {
         print "Mail not sent; error is " . (string) $sendResult->body->Error->Message . "\n";
     }
 }
コード例 #2
0
ファイル: test.php プロジェクト: jimjag/roundcubemail
    $from = idn_to_ascii(trim($_POST['_from']));
    $to = idn_to_ascii(trim($_POST['_to']));
    if (preg_match('/^' . $RCI->email_pattern . '$/i', $from) && preg_match('/^' . $RCI->email_pattern . '$/i', $to)) {
        $headers = array('From' => $from, 'To' => $to, 'Subject' => 'Test message from Roundcube');
        $body = 'This is a test to confirm that Roundcube can send email.';
        // send mail using configured SMTP server
        $CONFIG = $RCI->config;
        if (!empty($_POST['_smtp_user'])) {
            $CONFIG['smtp_user'] = $_POST['_smtp_user'];
        }
        if (!empty($_POST['_smtp_pass'])) {
            $CONFIG['smtp_pass'] = $_POST['_smtp_pass'];
        }
        $mail_object = new Mail_mime();
        $send_headers = $mail_object->headers($headers);
        $head = $mail_object->txtHeaders($send_headers);
        $SMTP = new rcube_smtp();
        $SMTP->connect(rcube_utils::parse_host($RCI->getprop('smtp_server')), $RCI->getprop('smtp_port'), $CONFIG['smtp_user'], $CONFIG['smtp_pass']);
        $status = $SMTP->send_mail($headers['From'], $headers['To'], $head, $body);
        $smtp_response = $SMTP->get_response();
        if ($status) {
            $RCI->pass('SMTP send');
        } else {
            $RCI->fail('SMTP send', join('; ', $smtp_response));
        }
    } else {
        $RCI->fail('SMTP send', 'Invalid sender or recipient');
    }
    echo '</p>';
}
?>
コード例 #3
0
ファイル: test.php プロジェクト: CDN-Sparks/owncloud
 $body = 'This is a test to confirm that Roundcube can send email.';
 $smtp_response = array();
 // send mail using configured SMTP server
 if ($RCI->getprop('smtp_server')) {
     $CONFIG = $RCI->config;
     if (!empty($_POST['_smtp_user'])) {
         $CONFIG['smtp_user'] = $_POST['_smtp_user'];
     }
     if (!empty($_POST['_smtp_pass'])) {
         $CONFIG['smtp_pass'] = $_POST['_smtp_pass'];
     }
     $mail_object = new Mail_mime();
     $send_headers = $mail_object->headers($headers);
     $SMTP = new rcube_smtp();
     $SMTP->connect(rcube_parse_host($RCI->getprop('smtp_server')), $RCI->getprop('smtp_port'), $CONFIG['smtp_user'], $CONFIG['smtp_pass']);
     $status = $SMTP->send_mail($headers['From'], $headers['To'], $foo = $mail_object->txtHeaders($send_headers), $body);
     $smtp_response = $SMTP->get_response();
 } else {
     // use mail()
     $header_str = 'From: ' . $headers['From'];
     if (ini_get('safe_mode')) {
         $status = mail($headers['To'], $headers['Subject'], $body, $header_str);
     } else {
         $status = mail($headers['To'], $headers['Subject'], $body, $header_str, '-f' . $headers['From']);
     }
     if (!$status) {
         $smtp_response[] = 'Mail delivery with mail() failed. Check your error logs for details';
     }
 }
 if ($status) {
     $RCI->pass('SMTP send');
コード例 #4
0
    //------------------------------------------------------------------------------
    $mime = new Mail_mime();
    // method 'addTo' exists in Mail_Mime-1.8.0+
    if (method_exists('Mail_mime', 'addTo')) {
        $mime->addTo($to);
    }
    $mime->setFrom($from);
    $mime->setSubject($subject);
    //$mime->addCc($cc);
    $mime->setTxtBody($body_text);
    //$mime->setHTMLBody($body_html);
    //------------------------------------------------------------------------------
    // get() must be called before headers()
    $body = $mime->get();
    // headers() must be called after get()
    $headers = $mime->txtHeaders();
    //$headers = $mime->headers();
    //------------------------------------------------------------------------------
    // send the problem
    if (!mail($to, $subject, $body, $headers)) {
        throw new Exception('"mail" function failed.');
    }
    $tmp1 = $e->getMessage();
    print <<<EOT
<p>There was an error.  Your results were <b>not</b> submitted.</p>

<p>The problem has been reported.</p>

<blockquote><p>{$tmp1}</p></blockquote>
EOT;
    unset($tmp1);