Wordpress wp_mail with attachment (with meaningful names)
How to use wp_mail function to send attachments with custom names for attachments.
At this point, the email is delivered with an attachment, but the file name is the same as the physical file name.
I cannot rename the files as we have many other links, but I want to submit these files with some meaningful name.
+3
Kuldeep singh
source
to share
2 answers
Thanks QArea for your answer. I found this place, need to edit wp-includes / pluggable.php wp_mail function to handle attachment, it should look like this:
if ( !empty( $attachments ) ) {
foreach ( $attachments as $name => $attachment ) {
try {
$phpmailer->AddAttachment($attachment, $name);
} catch ( phpmailerException $e ) {
continue;
}
}
}
+1
Kuldeep singh
source
to share
wp_mail does not support renaming attachments when sending emails. One way to change the file send names is to copy those files with new names, attach new files to email, and delete those files after the email is sent.
+1
QArea
source
to share