How to use the WordPress wp_mail();
function on a custom external PHP page using Advanced Email Options saved connection settings.
Furthermore the PHP page is hosted in /wp-content/wpmailtest.php
I would like to know if this is possible and if so, I would like a brief explanation.
By the way example@example.com is not my email and has been changed for the example below:-
include '../wp-load.php';
$to = 'example@example.com';
$subject = 'The subject';
$body = 'The email body content';
$headers = array('Content-Type: text/html; charset=UTF-8');
wp_mail($to, $subject, $body, $headers);
Moreover The mail is not sent. But my saved settings work when i do a send test in the wp-admin page in “Advanced Email Options” e.g. WP-Mail-SMTP Plugin—>Settings, run email test.
include this file in your custom php file on the top. then after you can access all wordpress functions inside that file. including
wp_mail()
function.