php - Sending email using smtp gmail in phpmailer -
i tried sending email using smtp gmail using phpmailer. gmail account got suspended saying there unusual activity. here code have used sending emails. what's correct way of sending emails using smtp gmail in phpmailer?
my question not duplicate. have tried : send email using gmail smtp server php page
i'm using phpmailer, , accounts getting suspended.
<?php include('phpmailer.php'); class mail extends phpmailer { // set default variables new objects public $from = 'noreply@exmaple.org'; public $fromname = sitetitle; public $host = 'smtp.gmail.com'; public $mailer = 'smtp'; public $smtpauth = true; public $username = 'username@gmail.com'; public $password = 'password'; public $smtpsecure = 'tls'; public $wordwrap = 75; public function subject($subject) { $this->subject = $subject; } public function body($body) { $this->body = $body; } public function send() { $this->altbody = strip_tags(stripslashes($this->body))."\n\n"; $this->altbody = str_replace(" ", "\n\n", $this->altbody); return parent::send(); } }
here php code :
$to = $_post['email']; $subject = "registration confirmation"; $body = "<p>thank registering @ demo site.</p> <p>to activate account, please click on link: <a href='".dir."activate.php?x=$id&y=$activasion'>".dir."activate.php?x=$id&y=$activasion</a></p> <p>regards site admin</p>"; $mail = new mail(); $mail->setfrom('noreply@example.org'); $mail->addaddress($to); $mail->subject($subject); $mail->body($body); $mail->send(); //redirect index page header('location: index.php?action=joined'); exit;
Comments
Post a Comment