Quantcast
Channel: WordPress.org Forums » [WP Mail SMTP by WPForms - The Most Popular SMTP and Email Log Plugin] Support
Viewing all articles
Browse latest Browse all 5001

sending SMTP email from PHP

$
0
0

Replies: 0

I have installed WPMail-SMTP using ‘other SMTP’ – my hosting provider – and the Test email works fine.
I want to generate emails from within a page PHP but I have been unable to get that to work. The code I have been using is below. The ‘From’ email (‘admin@mywebsite.nl’) is the same as the ‘SMTP Username’ and the ‘From email:’ on the WPMail-SMTP settings form.

Do you have any suggestions as to what I need to do to send emails from code?
Is there any way I can get some more helpful debug info? (at the moment all I can find is the return value of wp_mail: pass or fail)

add_filter('wp_mail_from','yoursite_wp_mail_from');
function yoursite_wp_mail_from($content_type) {	return 'admin@mywebsite.nl';}
add_filter('wp_mail_from_name','yoursite_wp_mail_from_name');
function yoursite_wp_mail_from_name($name) {return 'Admin';	}
$to = 'a.name@somemail.com';
$subject = 'My Subject ';
$body = '<p>The body of the email</p>';
$headers = array('Content-Type: text/html; charset=UTF-8');
if(wp_mail( $to, $subject, $body, $headers ))
{echo '<p>email SENT</p>';}
else
{echo '<p>email FAIL</p>';};

Viewing all articles
Browse latest Browse all 5001

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>