PhpMailer,发送附件作为其他名称 [英] PhpMailer, sent attachment as other name

查看:161
本文介绍了PhpMailer,发送附件作为其他名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用phpmailer发送电子邮件附件

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();

所以,如果使用这段代码,电子邮件被附加附件文件,文件名是:code> bla.csv

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

可以更改附件文件名而不重命名真实文件?也就是说,我需要发送 bla.csv 文件,但发送的名称是 some_other_name.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

如何做到这一点?

推荐答案

将所需的名称作为第二个参数传递

Pass the desired name as second parameter

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

这篇关于PhpMailer,发送附件作为其他名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆