rendered paste body function compose_and_send_mail( $mail_template ) {
$regex = '/\[\s*([a-zA-Z_][0-9a-zA-Z:._-]*)\s*\]/';
$use_html = (bool) $mail_template['use_html'];
$callback = array( &$this, 'mail_callback' );
$callback_html = array( &$this, 'mail_callback_html' );
$subject = preg_replace_callback( $regex, $callback, $mail_template['subject'] );
$sender = preg_replace_callback( $regex, $callback, $mail_template['sender'] );
$recipient = preg_replace_callback( $regex, $callback, $mail_template['recipient'] );
$additional_headers =
preg_replace_callback( $regex, $callback, $mail_template['additional_headers'] );
if ( $use_html ) {
$body = preg_replace_callback( $regex, $callback_html, $mail_template['body'] );
$body = wpautop( $body );
} else {
$body = preg_replace_callback( $regex, $callback, $mail_template['body'] );
}
$attachments = array();
foreach ( (array) $this->uploaded_files as $name => $path ) {
if ( false === strpos( $mail_template['attachments'], "[${name}]" ) || empty( $path ) )
continue;
$attachments[] = $path;
}
extract( apply_filters_ref_array( 'wpcf7_mail_components', array(
compact( 'subject', 'sender', 'body', 'recipient', 'additional_headers', 'attachments' ),
&$this ) ) );
$headers = "From: $sender\n";
if ( $use_html )
$headers .= "Content-Type: text/html\n";
$headers .= trim( $additional_headers ) . "\n";
return @wp_mail( $recipient, $subject, $body, $headers, $attachments );
}