从 PHPmailer 更改为 sendmail [英] Change from PHPmailer to sendmail

查看:46
本文介绍了从 PHPmailer 更改为 sendmail的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过原来的老派 sendmail 发送电子邮件.

I want to send the emails via original old school sendmail.

我需要以何种方式更改此代码才能使用 sendmail?

In what way i need to change this CODE to work with sendmail?

我已经尝试过,但总是遇到非常难看的错误,我尝试将 IsMail 更改为 IsSedmail,但仍然没有以原始方式发送.

i have tried but i always get very ugly errors, i tried to change IsMail to IsSedmail but still does not send the original way.

Phpmailer 发送了 3 封电子邮件,该网站需要花费很多时间才能发送,所以我想转到旧的普通邮件(到....",但问题是我迷失在所有代码中,所以请帮忙.

Phpmailer sends 3 email and the website is taking a lot time to send, so i want to go to the old plain "mail(to...." but the problem is that i`m lost in all the code so please Help.

function send_mail($rec_email,$subject,$message, $IsHtml=false, $cc=array(), $bcc=array()) {
    global $THIS_BASEPATH, $btit_settings;

    if (!method_exists('PHPMailer','IsMail'))
        include($THIS_BASEPATH.'/phpmailer/class.phpmailer.php');
    $mail=new PHPMailer();

    if ($btit_settings['mail_type']=='php') {
        $mail->IsMail();                                   # send via mail
        if (!empty($cc))
            $mail->AddCustomHeader('Cc: '.implode(',',$cc));
        if (!empty($bcc))
            $mail->AddCustomHeader('Bcc: '.implode(',',$bcc));
    } else {
        $mail->IsSMTP();                                   # send via SMTP
        $mail->Host     = $btit_settings['smtp_server'];   # SMTP servers
        $mail->Port     = $btit_settings['smtp_port'];     # SMTP port
        $mail->SMTPAuth = true;                            # turn on SMTP authentication
        $mail->Username = $btit_settings['smtp_username']; # SMTP username
        $mail->Password = $btit_settings['smtp_password']; # SMTP password
        if (!empty($cc))
            foreach($cc as $carbon_copy)
                $mail->AddCC($carbon_copy[0],$carbon_copy[0]);

        if (!empty($bcc))
            foreach($bcc as $blind_carbon_copy)
                $mail->AddBCC($blind_carbon_copy[0],$blind_carbon_copy[0]);
    }

    $mail->From     = $btit_settings['email'];
    $mail->FromName = $btit_settings['name'];
    $mail->CharSet  = $btit_settings['default_charset'];
    $mail->IsHTML($IsHtml);
    $mail->AddAddress($rec_email);
    $mail->AddReplyTo($btit_settings['email'],$btit_settings['name']);
    $mail->Subject  =  $subject;
    $mail->Body     =  $message;

    return ($mail->Send())?true:$mail->ErrorInfo;
}

非常感谢.

推荐答案

PHPmailer 不是缓慢"的罪魁祸首,它可能是您指定的 SMTP 服务器.但是不要停止使用 PHPmailer.PHPmailer 在幕后做了大量额外的事情来正确发送邮件.

PHPmailer is not the culrpit for "slowness", it's probably the SMTP server you've specified. Do not stop using PHPmailer, though. PHPmailer does tons of extra stuff behind the scenes to send mail correctly.

使用 PHP 的 mail() 替换通过本地服务器发送邮件:

To send mail out through the local server using PHP's mail() replace:

$mail->IsSMTP();                                   # send via SMTP
$mail->Host     = $btit_settings['smtp_server'];   # SMTP servers
$mail->Port     = $btit_settings['smtp_port'];     # SMTP port
$mail->SMTPAuth = true;                            # turn on SMTP authentication
$mail->Username = $btit_settings['smtp_username']; # SMTP username
$mail->Password = $btit_settings['smtp_password']; # SMTP password

与:

$mail->isMail();

就是这样.

如果您确定服务器安装了 Sendmail [或像 Postfix 或 Exim 这样的替代品],那么您可以使用:

If you are certain that the server has either Sendmail [or a drop-in replacement like Postfix or Exim] installed then you can use:

$mail->isSendmail();

但是,通过使用网络服务器发送您现在依赖的邮件:

However, by using the web server to send out mail you are now dependent on:

  1. 已正确配置已安装的 MTA,但他们经常没有正确配置.
  2. 根据各种黑名单的网络服务器声誉.通常,Web 服务器具有 s**t 声誉,因为任何人都可以在未经身份验证的情况下将出站邮件放入队列.

这篇关于从 PHPmailer 更改为 sendmail的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆