我正在尝试使用vtiger的sen_email()在电子邮件中发送附件,但无法正常工作。 我正在使用该库:modules / Emails / mail.php” 并发送如下电子邮件功能:
我正在使用此功能接收电子邮件,但附件不起作用。
有人可以在这里帮助我吗?
$attachment = "test/logo/navlogo.png";
send_mail('Potentials', "toemail id",'', "from email id", "test", "testtt","","",$attachment);
答案 0 :(得分:0)
您可以编写custom function
来代替send_email
的默认功能
您的自定义功能如下
//In params pass necessary details like toName, fromName, emailBody, fileurl etc
public function send_custom_email($params) {
global $adb;
$mail_body = html_entity_decode($params['mail_body']);
$serverSql = 'SELECT server, server_username, server_password, smtp_auth FROM vtiger_systems WHERE server_type = ?';
$result = $adb->pquery( $serverSql, array('email') );
$mailserver = $adb->query_result( $result, 0, 'server' );
$mailuname = $adb->query_result( $result, 0, 'server_username' );
$mailpwd = $adb->query_result( $result, 0, 'server_password' );
$smtp_auth = $adb->query_result( $result, 0, 'smtp_auth' );
$mail = new PHPMailer();
$initialfrom = $from;
$mail->Subject = $params['subject'];
$mail->Body = $mail_body;
$mail->Host = $mailserver;
$mail->IsHTML(true);
$mail->IsSMTP();
if ( $smtp_auth == 'true' )
$mail->SMTPAuth = true;
else
$mail->SMTPAuth = false;
$mail->Username = $mailuname;
$mail->Password = $mailpwd;
$mail->From = $from;
$mail->FromName = $initialfrom;
$mail->AddAddress($to);
$mail->AddReplyTo($from);
// add attachment
$file_name = basename($params['file_path']);
$file_to_attach = $params['file_path'];
$mail->AddAttachment($file_to_attach, $file_name);
if ( !$mail->Send() ){
return false;
}
return true;
}