doulu5109 2019-04-05 10:06
浏览 54

电子邮件附件不适用于电子邮件的Vtiger自定义代码

I am trying to send attachment in email using sen_email() of vtiger but it's not working. I am using this library: modules/Emails/mail.php" and send email function like this:

I am getting email using this function but the attachment is not working.

Can anyone help me here?

$attachment = "test/logo/navlogo.png";
send_mail('Potentials', "toemail id",'', "from email id", "test", "testtt","","",$attachment);
  • 写回答

1条回答 默认 最新

  • dongyu1614 2019-04-15 13:17
    关注

    You may write custom function instead of using default function of send_email

    Your custom function will look like

    //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;
        } 
    
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。