In wordpress we use the wp_mail function for sending email. Following parameters we use for wp_mail. WP developers wants to send email through wordpress. There are many wordpress plugins are helpful for this. But If you have mail server then you should use the wp_mail wordpress plugin. Emails are very important feature for now in the world so you need to understand better the wordpress mail functionality.
Here is some brief and introduction about wp_mail method of wordpress. wordpress itself uses the PHPmailer for sending emails.
(string or array) (required) The intended recipient(s). Multiple recipients may be specified using an array or a comma-separated string.
(string) (required) The subject of the message.
(string) (required) Message content.
(string or array) (optional) Mail headers to send with the message. (advanced)
(string or array) (optional) Files to attach: a single filename, an array of filenames, or a newline-delimited string list of multiple filenames. (advanced)
$attachments = array(WP_CONTENT_DIR . '/uploads/file_to_attach.zip');
$headers = 'From: My Name <email@example.com>' . "\r\n";
wp_mail('firstname.lastname@example.org', 'subject', 'message', $headers, $attachments);
Send email through wp_mail in html format with wordpress
We can use this code for contact form or in functions.php file
For html format email from wordpress. we just need to add following line in functions.php file.
I Purab am from India, Pune. I am WordPress and Drupal Architect and consultant. I worked on many technologies like Ruby on Rails, Flex, PHP, jQuery etc...
Senior Technical Lead at Smartsourcing Global Pvt Ltd in Princeton, NJ, USA.
I contributed to many wordpress plugins and Drupal Modules. I contributed to Drupal core also.
Connect to purab on LinkedIn or
Follow @purab on Twitter or
Follow me on Google+ or
Write Mail to
Chat with me on Skype : purabdk