Add attachment support to wp_mail. Fixes #7787 props AaronCampbell.
git-svn-id: http://svn.automattic.com/wordpress/trunk@9213 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
5ec329b4f1
commit
8453f12963
|
@ -253,11 +253,15 @@ if ( !function_exists( 'wp_mail' ) ) :
|
||||||
* @param string $subject Email subject
|
* @param string $subject Email subject
|
||||||
* @param string $message Message contents
|
* @param string $message Message contents
|
||||||
* @param string|array $headers Optional. Additional headers.
|
* @param string|array $headers Optional. Additional headers.
|
||||||
|
* @param string|array $attachments Optional. Files to attach.
|
||||||
* @return bool Whether the email contents were sent successfully.
|
* @return bool Whether the email contents were sent successfully.
|
||||||
*/
|
*/
|
||||||
function wp_mail( $to, $subject, $message, $headers = '' ) {
|
function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() ) {
|
||||||
// Compact the input, apply the filters, and extract them back out
|
// Compact the input, apply the filters, and extract them back out
|
||||||
extract( apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers' ) ) );
|
extract( apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) );
|
||||||
|
|
||||||
|
if ( !is_array($attachments) )
|
||||||
|
$attachments = explode( "\n", $attachments );
|
||||||
|
|
||||||
global $phpmailer;
|
global $phpmailer;
|
||||||
|
|
||||||
|
@ -406,6 +410,13 @@ function wp_mail( $to, $subject, $message, $headers = '' ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
error_log($attachments);
|
||||||
|
if ( !empty( $attachments ) ) {
|
||||||
|
foreach ( $attachments as $attachment ) {
|
||||||
|
$phpmailer->AddAttachment($attachment);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
do_action_ref_array( 'phpmailer_init', array( &$phpmailer ) );
|
do_action_ref_array( 'phpmailer_init', array( &$phpmailer ) );
|
||||||
|
|
||||||
// Send!
|
// Send!
|
||||||
|
|
Loading…
Reference in New Issue