问题
I want to send the emails via original old school sendmail.
In what way i need to change this CODE to work with sendmail?
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 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;
}
Thank You very much.
回答1:
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.
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
With:
$mail->isMail();
That's it.
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:
- The installed MTA being configured correctly, which they frequently aren't.
- The reputation of the web server according to various blacklists. Generally, web servers have s**t reputations because anyone can drop outbound mail into the queue without authentication.
来源:https://stackoverflow.com/questions/22078790/change-from-phpmailer-to-sendmail