PhpMailer, sent attachment as other name

守給你的承諾、 提交于 2019-12-23 08:39:38

问题


I use phpmailer for sending email with attachment

    file = "/path/bla.csv";


    require 'class.phpmailer.php';
    $mail = new PHPMailer();
    // some oprtions here

    $mail->AddAttachment($file);

    $mail->Send();

So, if use this code, email is sended with attach file, and file name is: bla.csv

There is possible to change attach file name without renaming real file? that is, I need sent bla.csv file, but sent is as name some_other_name.csv

How to make this?


回答1:


Pass the desired name as second parameter

$mail->AddAttachment($file, "newName.csv");


来源:https://stackoverflow.com/questions/16776073/phpmailer-sent-attachment-as-other-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!