Pergunta

Now I can send an email without attachment :

wp_mail( $to, $subject, $message, $headers);

But how can I send an email with attachment?

Foi útil?

Solução

 <?php wp_mail( $to, $subject, $message, $headers, $attachments ); ?> 

http://codex.wordpress.org/Function_Reference/wp_mail

Outras dicas

Refer below e.g.

$attachments = array(WP_CONTENT_DIR . '/uploads/file_to_attach.zip');
$headers = 'From: My Name <myname@mydomain.com>' . "\r\n";
wp_mail('test@test.com', 'subject', 'message', $headers, $attachments);
add_filter( 'wpcf7_mail_components', 'mycustom_wpcf7_mail_components' );

function mycustom_wpcf7_mail_components( $components ) {
    $components['attachments'][] = 'full path of your PDF file';

    return $components;
}

I wrote a plugin to send to emails with attachments from WP.

Quick Mail sends text or HTML emails with attachments from the dashboard. HTML emails can include shortcodes.

Get Quick Mail from WordPress or Github.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top