could not send mail using PHPMailer even after setting openssl in php.ini -
i m having trouble e-mail in php, want mail myself(just test), want use feature users can mail me thier feedback site.
i have enabled openssl in php.ini, i'm using wamp server 2.0 on localhost , win7 plzzz me out new php !!! here code:-
<?php require('phpmailer/class.phpmailer.php'); $mail = new phpmailer; $mail->issmtp(); // set mailer use smtp $mail->smtpdebug = 1; $mail->port = 587; $mail->host = 'mail.gmail.com'; // specify main , backup server $mail->smtpauth = true; // enable smtp authentication $mail->username = 'myid@gmail.com'; // smtp username $mail->password = 'password'; // smtp password $mail->smtpsecure = 'ssl'; // enable encryption, 'ssl' accepted $mail->from = 'myid@gmail.com'; $mail->fromname = 'ashimailer'; $mail->addaddress('myid.sbit@gmail.com', 'josh adams'); // add recipient $mail->addaddress('myid@gmail.com'); // name optional $mail->addreplyto('myid@gmail.com', 'information'); //$mail->addcc('cc@example.com'); //$mail->addbcc('bcc@example.com'); $mail->wordwrap = 50; // set word wrap 50 characters //$mail->addattachment('/var/tmp/file.tar.gz'); // add attachments //$mail->addattachment('/tmp/image.jpg', 'new.jpg'); // optional name $mail->ishtml(true); // set email format html $mail->subject = 'here subject'; $mail->body = 'this html message body <b>in bold!</b>'; $mail->altbody = 'this body in plain text non-html mail clients'; if(!$mail->send()) { echo 'message not sent.'; echo 'mailer error: ' . $mail->errorinfo; exit; } echo 'message has been sent'; ?>
use these settings
$mail->smtpsecure = 'tls'; $mail->host = 'smtp.gmail.com';
Comments
Post a Comment