我想通過原來的老派sendmail發送電子郵件。從PHPmailer更改爲sendmail
以什麼方式我需要更改此代碼以使用sendmail?
我已經嘗試過,但我總是得到非常醜陋的錯誤,我試圖將IsMail更改爲IsSedmail,但仍然不會發送原始方式。
Phpmailer發送3封電子郵件和網站花了很多時間發送,所以我想去舊的平原「郵件(到...」,但問題是,我在所有的代碼丟失了所以請大家幫忙。
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;
}
非常感謝你。
首先你說* sendmail *,然後* mail()* php函數,這些是不一樣的東西 – 2014-02-27 19:50:58
** comment **整個函數的代碼和地方只有'mail(to ....)與所需參數 – Girish
PHPMailer可以使用郵件(),壞主意,但它有配置。使用郵件的基本示例:http://phpmailer.worxware.com/?pg=examplebsendmail – 2014-02-27 19:51:46