I had some problems sending php emails using servers that require authentication like google or yahoo. I was told that PHPMAILER is the best solution to my problem. Well, I have installed it right (I think so because it I tried the installation test & there were no errors), configured the class.phpgmailer.php & tried to send an email through php codes but I always get this error "Message was not sent.Mailer error: SMTP Error: Could not connect to SMTP host."
I tried to use smtp.gmail.com or smtp.mail.yahoo.com but it's useless..I always get the same error. I thought I should show you the class.phpgmailer.php & the php codes I use to send the email, maybe somebody can tell me how to solve such a problem. I included only the important lines in class.phpgmailer.php file.
The php codes I use for sending emails
Any ideas ?!! Let me know if the configuration is right or not, & how may I solve this problem. Thanks.
I tried to use smtp.gmail.com or smtp.mail.yahoo.com but it's useless..I always get the same error. I thought I should show you the class.phpgmailer.php & the php codes I use to send the email, maybe somebody can tell me how to solve such a problem. I included only the important lines in class.phpgmailer.php file.
Code:
<?php
class PHPMailer {
var $Priority = 3;
var $CharSet = 'iso-8859-1';
var $ContentType = 'text/plain';
var $Encoding = '8bit';
var $ErrorInfo = '';
var $From = 'my_user_name@gmail.com';
var $FromName = 'my_user_name@gmail.com';
var $Sender = 'my_user_name@gmail.com';
var $Subject = '';
var $Body = '';
var $AltBody = '';
var $WordWrap = 999999;
var $Mailer = 'smtp';
var $Sendmail = '/usr/sbin/sendmail';
var $PluginDir = '';
var $Version = "2.0.3";
var $ConfirmReadingTo = '';
var $Hostname = 'smtp.gmail.com';
var $MessageID = '';
var $Host = 'smtp.gmail.com';
var $Port = 465;
var $Helo = '';
var $SMTPSecure = "ssl";
var $SMTPAuth = true;
var $Username = 'my_user_name@gmail.com';
var $Password = 'my_password';
The php codes I use for sending emails
Code:
<?php
require("class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "smtp.gmail.com"; // SMTP server
$mail->From = "my_user_name@gmail.com";
$mail->AddAddress("my_user_name@gmail.com");
$mail->Subject = "First PHPMailer Message";
$mail->Body = "Hi! \n\n This is my first e-mail sent through PHPMailer.";
$mail->WordWrap = 50;
if(!$mail->Send()) {
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent.';
}
?>
Any ideas ?!! Let me know if the configuration is right or not, & how may I solve this problem. Thanks.