Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PhpMailer, sent attachment as other name

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?

like image 859
Oto Shavadze Avatar asked May 27 '13 15:05

Oto Shavadze


Video Answer


1 Answers

Pass the desired name as second parameter

$mail->AddAttachment($file, "newName.csv");
like image 80
fab Avatar answered Oct 16 '22 19:10

fab