Setting the Filename
Usually you don't need to explicitly set the filename of an attachment because the name of the attached file will be used by default, but if you want to set the filename you use the setFilename() method of the Attachment.
To change the filename of an attachment:
Call its setFilename() method.
The attachment will be attached in the normal way, but meta-data sent inside the email will rename the file to something else.
//Create the attachment and call its setFilename() method
$attachment = Swift_Attachment::fromPath('/path/to/image.jpg')
->setFilename('cool.jpg');
//Because there's a fluid interface, you can do this in one statement
$message->attach(
Swift_Attachment::fromPath('/path/to/image.jpg')->setFilename('cool.jpg')
);
Parent topic: Attaching Files
Previous topic: Attaching Existing Files
Next topic: Attaching Dynamic Content