dongqing6755 2013-11-12 06:18
浏览 27

wp_mail附件不能动态工作

I have edited function send() to attach the file in woo commerce plugin when, I am use the attachment file path statically it work's but when, I put it on dynamically attachment source not able send the attachment but, I am getting mail.I am using select query for getting image from database to attach in mail.

function send( $to, $subject, $message, $headers, $attachments ) {
 global $wpdb;

             $current_post1=$post->ID; 
    $result1=$wpdb->get_results("SELECT BgImageName FROM ca_woocommerce_order_items where order_id = $current_post1 ");

     foreach ( $result1 as $print1 )  
     echo $imgemail=$print1->BgImageName;


      //static path it's work
   //$attachments = array(  '/home2/rahulr/public_html/cutting-edge/wordpress_theme/user_templates/1384010402.png' );  

     //dynamic path it's not working
   $attachments = array('/home2/rahulr/public_html/cutting-edge/wordpress_theme/user_templates/'.$imgemail);


        add_filter( 'wp_mail_from', array( $this, 'get_from_address' ) );
        add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) );
        add_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) );

        wp_mail( $to, $subject, $message, $headers, $attachments );

        remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ) );
        remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) );
        remove_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) );
    }
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 stm32开发clion时遇到的编译问题
    • ¥15 lna设计 源简并电感型共源放大器