Skip to content

Instantly share code, notes, and snippets.

@bordoni
Last active July 8, 2024 15:19
Show Gist options
  • Save bordoni/8731880 to your computer and use it in GitHub Desktop.
Save bordoni/8731880 to your computer and use it in GitHub Desktop.
How to Send an Email via WordPress | Article on Sending emails on WordPress -- http://bordoni.me/wordpress/send-wordpress-email/
<?php
$to = "[email protected]";
$subject = "Learning how to send an Email in WordPress";
$content = "WordPress knowledge";
$headers = [
'Reply-To' => "Gustavo Bordoni <[email protected]>"
];
$status = wp_mail( $to, $subject, $content, $headers );
<?php
$to = "[email protected]";
$subject = "Learning how to send an Email in WordPress";
$content = "WordPress <b>knowledge<b>";
$set_content_type_callback = static function () {
return 'text/html';
};
add_filter( 'wp_mail_content_type', $set_content_type_callback );
$status = wp_mail( $to, $subject, $content );
// Reset content-type to avoid conflicts -- http://core.trac.wordpress.org/ticket/23578
remove_filter( 'wp_mail_content_type', $set_content_type_callback );
<?php
$to = [
"Gustavo Bordoni <[email protected]>",
"WordPress Developer <[email protected]>",
"[email protected]"
];
$subject = "Learning how to send an Email in WordPress";
$content = "WordPress knowledge";
$status = wp_mail( $to, $subject, $content );
<?php
$to = "[email protected]";
$subject = "Learning how to send an Email in WordPress";
$content = "WordPress knowledge";
$status = wp_mail( $to, $subject, $content );
@itsprabhucbe
Copy link

Helpful info.. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment