require_once "Mail.php"; function send_mail_pear (){ $mail_to = This email address is being protected from spambots. You need JavaScript enabled to view it., This email address is being protected from spambots. You need JavaScript enabled to view it.'; $mail_subject = 'Enquiry From Website'; $mail_from = 'My Website <webmaster@domain>'; // make sure email is authorised in your AuthSMTP account $mail_body = 'Email body HTML'; $headers = array( 'From' => $mail_from, 'To' => $mail_to, 'Subject' => $mail_subject, 'Content-type' => 'text/html; charset=utf-8'); $smtp = Mail::factory('smtp', array( 'host' => 'ssl://mail.authsmtp.com', 'port' => '465', 'auth' => true, 'debug' => false, 'username' => 'accountId', // Your AuthSMTP account username 'password' => 'Password' // Your AuthSMTP account password )); $mail = $smtp->send($mail_to, $headers, $mail_body); if (PEAR::isError($mail)) { //Email sending failed (to troubleshoot set 'debug' => true) return (false); } else{ // Email was sent successfully return (true); } }
January 2017