Tuesday 17 February 2015

How to send Email in wordpress

How to send Email in wordpress

In Websites, we need to send email on Registration, Forget password, order to our Clients/Customer. If your email template is ready Sending email is a very quick step in WordPress, but sometimes developer gets confused due to not available of correct email sending code.

In this post, We will give you code snippet. This code snippet will send email. You can set the receipt, subject, description, reply-to and header  in email.

$receipt = "user@no-spam.ws"; 
$subject = "This is subject";
$content = 'This is conent of the email.


http://www.web-technology-experts-notes.in';
/** Set the Reply -optional field **/
$headers = array(
 'Reply-To' => "replyto@no-spam.ws"
);
/** Set the Reply -optional field **/


/** Send the Html email - optional field **/
add_filter( 'wp_mail_content_type', 'set_html_content_type' );
/** Send the Html email - optional field **/

$status = wp_mail($receipt, $subject, $content, $headers);

if($status){
echo 'Sent Successfully';
}else{
echo 'Not send';
}
  


If above any query regarding above code, Please comment!.