I want to send an email with PHPMailer class to my email address(ramin.badri69@gmail.com) This is my code:
<?php
require_once('class.phpmailer.php');
require_once('class.smtp.php');
require_once('PHPMailerAutoload.php');
$mail = new PHPMailer();
$mail->addAddress('ramin.badri69@gmail.com');
$mail->setFrom('asbd@gmail.com','ramin');
$mail->addReplyTo('asd@gmail.com');
$mail->Subject ='HI';
$mail->Body ='<h2>Hello World!</h2>';
$mail->isHTML(true);
$mail->isSMTP();
$mail->SMTPAuth =true;
$mail->SMTPSecure='ssl';
$mail->Host ='ssl://smtp.gmail.com';
$mail->Port=456;
$mail->Username='farzin.badri@gmail.com';
$mail->Password='*****';
if($mail->send()){
echo "<h3>message sent.</h3>";
}else{
echo "<h3>Error</h3>";
}
But I see "ERROR" every time I run it. Both "ramin.badri" and "farzin.badri" are valid email addresses. I have downloaded PHPMailer class already and attached it to the current PHP script as you can see above. Help me on this code,I cant see any new email in the my inbox(ramin.badri69@gmail.com is my email).
I found the problem...in my PHP page,I wrote $mail->port
instead of $mail->Port
! But here in the stackOverflow I wrote with upper-case word! So,be careful of such a tiny hidden problem in your PHP projects,all attributes should begin with upper-case words and in all methods you should observe camel-notation.