php - Can solve my "SMTP Error: Could not authenticate" error -
i have problem phpmailer function.
i want registration form send mail every new registered member.
i error code. smtp error: not authenticate.
i have contacted webhost, , have right username,password, smtp server etc.
include "class.smtp.php"; include "class.phpmailer.php"; $host = "mail.smtp.com"; // smtp servers $username = "support@mymail.com"; // smtp password $password = "mymailpassword"; $from = "support@mymail.com"; $fromname = "my name"; $toemail = $mail; $toname = $username; $header = str_replace('%homepage_url%', $hp_url, $_language->module['mail_subject']); $message = str_replace(array('%nickname%', '%username%', '%password%', '%activationlink%', '%pagetitle%', '%homepage_url%'), array(stripslashes($nickname), stripslashes($username), stripslashes($pwd1), stripslashes($validatelink), $hp_title, $hp_url), $_language->module['mail_text']); $mail = new phpmailer(); $mail->issmtp(); // send via smtp $mail->host = $host; $mail->smtpauth = true; // turn on smtp authentication $mail->username = $username; $mail->password = $password; $mail->from = $from; $mail->fromname = $fromname; $mail->addaddress($toemail , $toname); $mail->wordwrap = 50; // set word wrap $mail->priority = 1; $mail->ishtml(true); $mail->subject = $header; $mail->altbody = "to view message, please use html compatible email viewer!"; // optional, comment out , test $mail->msghtml($message); $mail->charset="utf-8"; if(!$mail->send()){ redirect("index.php",$_language->module['register_successful'],10); $show = false; } else { redirect("index.php",$_language->module['register_successful'],10); $show = false; }
Comments
Post a Comment