Exemple #1
0
function SendMail($inputMail, $validateKey, $inputReturnPage)
{
    // 发送确认邮件
    $commonDao = new CommonDao();
    $mailUserName = "";
    $mailPassword = "";
    $localhost = "";
    $commonDao->GetConfig("mail.user_name", $mailUserName);
    $commonDao->GetConfig("mail.password", $mailPassword);
    $commonDao->GetConfig("localhost", $localhost);
    $mail = new PHPMailer();
    PHPMailerSendFromQqConfig($mail, $mailUserName, $mailPassword);
    //Set who the message is to be sent to
    $mail->addAddress($inputMail, $inputMail);
    //Set the subject line
    $mail->Subject = '登录验证';
    $href = "http://" . $localhost . "/php_learn/apps/common/login_validate.html" . "?mail=" . $inputMail . "&validate_key=" . $validateKey . "&return_page=" . urlencode($inputReturnPage);
    $mail->msgHTML("您好,你刚刚使用了这个邮件尝试登录:<br />" . "请在同一浏览器<a href=\"{$href}\">点击</a>完成验证。<br />" . "如果不能点击,请使用这个链接: {$href}<br />");
    if (!$mail->send()) {
        return __LINE__;
    }
    return 0;
}
Exemple #2
0
function SendMails($dao)
{
    $mailUserName = "";
    $mailPassword = "";
    $dao->GetConfig("mail.user_name", $mailUserName);
    $dao->GetConfig("mail.password", $mailPassword);
    $getUsersIn = new Dao_GetUsersToInformUpdateIn();
    $getUsersOut = new Dao_GetUsersToInformUpdateOut();
    $dao->GetUsersToInformUpdate($getUsersIn, $getUsersOut);
    $users = $getUsersOut->users;
    GetLogger()->info(count($users) . " users need to inform.");
    foreach ($users as $user) {
        $from = $mailUserName;
        $passwrod = $mailPassword;
        $ruleId = $user["i_rule_id"];
        $url = $user["s_url"];
        $pattern = $user["s_pattern"];
        $subscriber = $user["s_subscriber"];
        // send mail
        $mail = new PHPMailer();
        PHPMailerSendFromQqConfig($mail, $from, $passwrod);
        //Set who the message is to be sent to
        $mail->addAddress($subscriber, $subscriber);
        //Set the subject line
        $mail->Subject = 'update notify';
        $mail->msgHTML(htmlspecialchars($url));
        if (!$mail->send()) {
            GetLogger()->error("send mail to {$subscriber} error, url[{$url}]");
            continue;
        }
        $updateInformTimeIn = new Dao_UpdateUserInformTimeIn();
        $updateInformTimeIn->ruleId = $ruleId;
        $updateInformTimeIn->subscriber = $subscriber;
        $updateInformTimeOut = new Dao_UpdateUserInformTimeOut();
        $dao->UpdateUserInformTime($updateInformTimeIn, $updateInformTimeOut);
    }
}
$output = new AppointmentDaoCreateRequestOutput();
$input->issueId = CgiInput("issue_id", "");
$input->subIssueId = CgiInput("sub_issue_id", "");
$input->mail = CgiInput("mail", "");
$input->fields = CgiInput("fields", "");
$input->validateKey = rand(1, 999999);
if ($input->mail == "") {
    CgiOutput(__LINE__, "邮箱不能为空");
}
// 发送确认邮件
$commonDao = new CommonDao();
$mailUserName = "";
$mailPassword = "";
$localhost = "";
$commonDao->GetConfig("mail.user_name", $mailUserName);
$commonDao->GetConfig("mail.password", $mailPassword);
$commonDao->GetConfig("localhost", $localhost);
$mail = new PHPMailer();
PHPMailerSendFromQqConfig($mail, $mailUserName, $mailPassword);
//Set who the message is to be sent to
$mail->addAddress($input->mail, $input->mail);
//Set the subject line
$mail->Subject = '报名/预约确认';
$href = "http://" . $localhost . "/php_learn/apps/appointment/appointment_validate.php" . "?issue_id=" . $input->issueId . "&sub_issue_id=" . $input->subIssueId . "&mail=" . $input->mail . "&validate_key=" . $input->validateKey;
$mail->msgHTML("您好,您刚刚预约了活动,信息如下:<br />" . htmlspecialchars($input->fields) . "<br />请<a href=\"{$href}\">点击确认</a>。");
//if (!$mail->send()) {
//	CgiOutput($error, "发送确认邮件失败");
//}
$dao = new AppointmentDao();
$error = $dao->CreateRequest($input, $output);
CgiOutput($error, $output->errorMessage);