当前位置: 首页>>代码示例>>PHP>>正文


PHP Mailer::Body方法代码示例

本文整理汇总了PHP中Mailer::Body方法的典型用法代码示例。如果您正苦于以下问题:PHP Mailer::Body方法的具体用法?PHP Mailer::Body怎么用?PHP Mailer::Body使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mailer的用法示例。


在下文中一共展示了Mailer::Body方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: strtotime

$credID = mysql_result($r, 0);
// Make sure they haven't requested a reset in the last 15 minutes.
$q = "SELECT `Timestamp` FROM `PwdResetTokens` WHERE `CredentialsID`='{$credID}' ORDER BY `ID` DESC LIMIT 1";
// Find most recent
$result = mysql_fetch_array(DB::Run($q));
$tooSoon = strtotime("+15 minutes", strtotime($result['Timestamp']));
if (time() < $tooSoon) {
    Response::Send(403, "Please wait at least 15 minutes before requesting another email to be sent.");
}
// Generate reset token
$token = urlencode(randomString(15, false));
// Prepare the email
$subj = "Reset your ward website password";
$msg = "Hi!\n\nYou or somebody else is trying to log in with this account on " . SITE_DOMAIN . ".\n\nTo reset your password, go to:\n\n----------------------------------------------------\nhttps://" . SITE_DOMAIN . "/newpwd?key={$token}\n----------------------------------------------------\n\nIf you didn't ask for a password reset, just ignore and delete this message. It expires in 48 hours anyway.\n\nHave a great day!\n-" . SITE_DOMAIN;
// Save the reset token in the DB
$q = "INSERT INTO `PwdResetTokens` (CredentialsID, Token, Timestamp) VALUES ('{$credID}', '{$token}', CURRENT_TIMESTAMP)";
if (!DB::Run($q)) {
    Response::Send(500, "Couldn't save password reset token. Please report this: " . mysql_error());
}
// Send the email
$mail = new Mailer();
$mail->FromAndReplyTo(SITE_NAME, "no-reply@" . SITE_DOMAIN);
$mail->Subject("Reset your ward website password");
$mail->Body($msg);
$mail->To("", $eml);
$mail->Send();
if (count($mail->FailedRecipients()) > 0) {
    Response::Send(500, "Could not send password reset email. Please try again, or report this if the problem persists.");
}
// Send 200 OK. Email sent; we're done here.
Response::Send(200);
开发者ID:bluegate010,项目名称:ysaward,代码行数:31,代码来源:resetpwd.php

示例2: fail

// Currently, these actual rates mean we can send about 4,500 emails in an hour. An email to an entire
// ward with, say, 160 members, would take just over 2 minutes. Previously, at 1 per second, it would take just under 3 minutes.
// TODO: If we are seeing a high volume of emails:
//  - Spawn up other threads to handle a single job, if the job is large enough, like stake-wide. Deal with concurrency. Yay...
//  - See if 2 or more other jobs are running; if so, wait time before trying. Run anyway after a certain length of time.
// Mark the job as started if not already. If already started or missing info, bail.
if ($job->Started > 0 || !$job->Subject || !$job->Message || !$job->SenderName() || !$job->SenderEmail()) {
    fail("Job properties incorrect (already started, or missing necessary information.\r\n");
}
// Ready... set... go!
$job->Started = now();
$job->Save();
// Prepare and send the emails
$mail = new Mailer();
$mail->IsHTML($job->IsHTML);
$mail->From($job->SenderName(), EMAIL_FROM);
$mail->ReplyTo($job->SenderName(), $job->SenderEmail());
$mail->Subject($job->Subject);
$mail->Body($job->Message);
$mail->RecipientArray($job->RecipientsAsArray());
// Send the messages!
$mail->Send();
// Store the list of those who didn't receive the email for whatever reason
$failedRecipients = $mail->FailedRecipients();
foreach ($failedRecipients as $recip) {
    $job->AddFailedRecipient($recip['name'], $recip['email']);
}
// This deed is done.
$job->Ended = now();
$job->Save();
exit;
开发者ID:bluegate010,项目名称:ysaward,代码行数:31,代码来源:sendemails.php

示例3: Mailer

 if ($segment->status == 0) {
     // Successful send.
     // Convert cost from EUR to USD (https://getsatisfaction.com/nexmo/topics/is_the_message_price_thats_returned_from_a_rest_request_in_eur_or_usd)
     $job->Cost += $segment->{'message-price'} * $euroToUsd;
 } else {
     // Problem sending.
     // Status codes available at: https://docs.nexmo.com/index.php/messaging-sms-api/send-message
     if ($segment->status == 2 || $segment->status == 3 || $segment->status == 4 || $segment->status == 8 || $segment->status == 9 || $segment->status == 12 || $segment->status == 19 || $segment->status == 20) {
         // All of those codes should terminate the whole job because they're all show-stoppers.
         // Status Code 9 is the most likely: "Partner quota exceeded," meaning:
         // "Your pre-pay account does not have sufficient credit to process this message"
         // Alert the webmaster via email because this will require attention.
         $mail = new Mailer();
         $mail->FromAndReplyTo(ERR_HANDLE_FROM_NAME, EMAIL_BLACKHOLE);
         $mail->Subject("Ward website alert: SMS provider returned fatal error during send");
         $mail->Body("While sending a text message from the ward website:\n\nStatus Code {$segment->status}\n\nReason:" . $segment->{'error-text'} . "\n\nJob ID " . $job->ID() . " ended unexpectedly.");
         $mail->To(WEBMASTER_NAME, WEBMASTER_EMAIL);
         $mail->Send();
         $errorCode = $segment->status;
         $errorReason = $segment->{'error-text'};
         $abort = true;
         break;
     } else {
         if ($job->Recipients[$i]->attempts >= SMS_MAX_ATTEMPTS_PER_RECIPIENT) {
             // Can't try anymore for this recipient; already tried maximum number of times.
             $job->AddFailedRecipient($recipID, $recipName, $recipPhone, $segment->status, $segment->{'error-text'});
             break;
             /*
             	NOTE: At some point, something changed with Nexmo which doesn't allow multi-segment (concatenated)
             	messages to US carriers, and each one would get a "throttled" error. They used to automatically
             	split the message up and send them in segments for us. (I suspect this breaking change, which
开发者ID:bluegate010,项目名称:ysaward,代码行数:31,代码来源:sendsms.php

示例4: errorHandler

function errorHandler($level, $errorMsg, $file, $line)
{
    // Don't handle it if the error was suppressed (maybe with @) (or error reporting is off)
    if (!error_reporting()) {
        return true;
    }
    $errorType;
    if ($level == E_USER_ERROR) {
        $errorType = "Error";
    } else {
        if ($level == E_USER_WARNING) {
            $errorType = "Warning";
        } else {
            if ($level == E_USER_NOTICE) {
                $errorType = "Notice";
            } else {
                $errorType = "Unknown";
            }
        }
    }
    $alertSubject = $errorType . ": " . $errorMsg;
    $alertBody = "FILE: {$file}\r\nLINE: {$line}\r\nPROBLEM: {$errorType}: {$errorMsg}\r\n";
    // See if there's a logged-in user
    $user = Member::Current();
    if (!$user) {
        $user = StakeLeader::Current();
    }
    if ($user) {
        $alertBody .= "Currently logged-in user:\r\n" . print_r($user, true);
    }
    $alertBody .= "\r\n\r\n--\r\nAutomatically generated by the PHP error handling subsystem for debugging purposes.";
    $mail = new Mailer();
    $mail->FromAndReplyTo(ERR_HANDLE_FROM_NAME, EMAIL_BLACKHOLE);
    $mail->Subject($alertSubject);
    $mail->Body($alertBody);
    $mail->To(WEBMASTER_NAME, WEBMASTER_EMAIL);
    $mail->Send();
    // Write this to the server's internal log file...
    error_log("{$errorType}: {$errorMsg} in {$file} on line {$line}\n", LOG_TYPE, LOG_FILE);
    // Don't execute PHP's internal error handler
    return true;
}
开发者ID:bluegate010,项目名称:ysaward,代码行数:42,代码来源:functions.php


注:本文中的Mailer::Body方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。