How to use wp_mail function to send attachments with custom names for the attached files.
As of now email is getting delivered with attachment but name of files are same as physical file name.
I can't rename the files as we have lots of other references, but I want to send those files with some meaningful name.
wp_mail doesn't support rename the attachment when sending emails. The one way to change names of sending files is copying this files with new names, attach new files to the email and delete this files after sending email.
Thanks QArea for your response. I found the place though, one need to edit the wp-includes/pluggable.php wp_mail function for processing attachment, It should look like this
if ( !empty( $attachments ) ) {
foreach ( $attachments as $name => $attachment ) {
try {
$phpmailer->AddAttachment($attachment, $name);
} catch ( phpmailerException $e ) {
continue;
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With