sending SMTP email from PHP
-
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 (‘[email protected]’) 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 '[email protected]';} add_filter('wp_mail_from_name','yoursite_wp_mail_from_name'); function yoursite_wp_mail_from_name($name) {return 'Admin'; } $to = '[email protected]'; $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 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘sending SMTP email from PHP’ is closed to new replies.