Example #1
0
function send_email($email, $subject, $template, $ip, $a_origin, $a_dest, $instant_deliver = true)
{
    $errno = can_send_to($email, $ip);
    if ($errno != 0) {
        return $errno;
    }
    $smtpemailto = $email;
    //send to whom
    $subject = $subject;
    //subject
    $content = file_get_contents($template);
    if (count($a_origin) != count($a_dest)) {
        return 4;
    }
    for ($i = 0; $i < count($a_origin); $i++) {
        $content = str_replace($a_origin[$i], $a_dest[$i], $content);
    }
    $smtp = new Smtp(SMTPSERVER, SMTPSERVERPORT, true, SMTPUSER, SMTPPASS);
    //这里面的一个true是表示使用身份验证,否则不使用身份验证.
    $smtp->debug = false;
    //是否显示发送的调试信息
    if ($smtp->sendmail($smtpemailto, SMTPUSERMAIL, $subject, $content, MAILTYPE)) {
        return 0;
    } else {
        return 3;
    }
}
Example #2
0
function send_verify_mail($username, $email, $auth_key, $ip)
{
    $tmp = can_send_to($email, $ip);
    if ($tmp != 0) {
        return $tmp;
    }
    $smtpemailto = $email;
    //send to whom
    $subject = 'Verify your email address | QuickAuth';
    //subject
    $content = file_get_contents('templates/verify_en.tpl');
    $content = str_replace('<%username%>', $username, $content);
    $content = str_replace('<%email%>', $email, $content);
    $content = str_replace('<%auth_key%>', $auth_key, $content);
    $smtp = new smtp(SMTPSERVER, SMTPSERVERPORT, true, SMTPUSER, SMTPPASS);
    //这里面的一个true是表示使用身份验证,否则不使用身份验证.
    $smtp->debug = false;
    //是否显示发送的调试信息
    if ($smtp->sendmail($smtpemailto, SMTPUSERMAIL, $subject, $content, MAILTYPE)) {
        return 0;
    } else {
        return 3;
    }
}