[wp-trac] [WordPress Trac] #28407: You are unable to override the attachment name in wp_mail() when adding attachments
WordPress Trac
noreply at wordpress.org
Fri May 30 16:15:51 UTC 2014
#28407: You are unable to override the attachment name in wp_mail() when adding
attachments
-------------------------+-----------------------------
Reporter: syntaxart | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Mail | Version: 3.9.1
Severity: normal | Keywords:
Focuses: |
-------------------------+-----------------------------
Hi,
When you create an email and add an attachment your may have obtained the
attachment filepath using the file upload control. This means you will
have a .tmp file extension on your email attachment. When the user
receives the email, the attachment is not useful. In order to get the
attachment to work correctly you need to first add the tmp filepath and
then override the filename. PHPMailer allows you to do this with the
AddAttachment function. The wordpress wp_mail function does not allow for
this to happen.
The problem with wp_mail() in wp-includes/pluggable.php is at line 483
{{{
if ( !empty( $attachments ) ) {
foreach ( $attachments as $attachment ) {
try {
$phpmailer->AddAttachment($attachment);
} catch ( phpmailerException $e ) {
continue;
}
}
}
}}}
I overcame this problem by copying the function and then replacing the
above block of code with
{{{
if (!empty($attachments)) {
foreach ($attachments as $name => $attachment) {
try {
$phpmailer->AddAttachment($attachment, $name);
} catch (phpmailerException $e) {
continue;
}
}
}
}}}
The wp_mail function is an important core function and in my opinion is
best not to override.
Is it possible to enhance the wp_mail function for this. I have read
forums on the internet which has pointed to the issue above. It would be
good to offer some of the features which phpmailer is offering.
Thank you very much.
Ryan
--
Ticket URL: <https://core.trac.wordpress.org/ticket/28407>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list