As we know that we have a mail function mail() in Php which can be used to send plain text mail, HTML mail and mail with attachment. In the Php mail() function it is easy to send plain text mail or HTML mail but a little hard to send a Mail with attachment. But don’t worry in wordpress you can use a simple function wp_mail() through which you can send mail with any number of files attached with it very easily :) Yes you heard it right, wordpress provides a mailing function through which you can send e-mail easily.

Here is function Description:-

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

$to: Use string for a single recipient E-mail ID or an Array of strings which contain multiple E-mail IDs.

$subject: Subject of the message. (similar like in php mail() function)

$message: Message to be sent. (similar like in php mail() function)

$header: Mail header which contain optional information like “from”, “reply-to” etc. (similar like in php mail() function)

$attachments: array of strings which contains the path of the files that need to be attached with the mail.

return: This function returns boolean true if mail is successfully send or else return boolean false on failure.