Skip to content

Instantly share code, notes, and snippets.

View mflisikowski's full-sized avatar
🎯
Focusing

Mateusz Flisikowski mflisikowski

🎯
Focusing
View GitHub Profile
<?php
/**
* Adapted from https://wordpress.stackexchange.com/a/191974/8591
*
* Send mail, similar to PHP's mail
*
* A true return value does not automatically mean that the user received the
* email successfully. It just only means that the method used was able to
* process the request without any errors.
*
@mflisikowski
mflisikowski / function.php
Created July 20, 2020 22:06 — forked from nandomoreirame/function.php
WordPress REST API send email SMTP in with PHPMailer
<?php
function sendWithPhpMailer($subject, $body, $reply) {
require(ABSPATH . WPINC . '/class-phpmailer.php');
require(ABSPATH . WPINC . '/class-smtp.php');
// date_default_timezone_set( 'America/Sao_Paulo' );
$blogname = wp_strip_all_tags( trim( get_option( 'blogname' ) ) );
$smtpHost = wp_strip_all_tags( trim( get_option( 'smtp_host' ) ) );