Sending mail
Posted: Thu Sep 24, 2009 1:29 pm
Hi guys,
I have been trying to send a mail thru php for a long time. I am always kicked off with errors, I tries both sendmail and phpmailer, but the farthest I could get was with this code
I dont get an error and at the same time the mail is not sent
I have been trying to send a mail thru php for a long time. I am always kicked off with errors, I tries both sendmail and phpmailer, but the farthest I could get was with this code
Code: Select all
class gMailer extends PHPMailer {
/** CHANGE THESE AS REQUIRED **/
public $From = "rzphpmailer@gmail.com"; //PUT YOUR ADDRESS HERE
public $FromName = "rzphpmailer"; //PUT YOUR NAME HERE
public $Password = "***********"; //PUT YOUR PASSWORD HERE
/** DO NOT CHANGE THESE **/
public $Host = "smtp.gmail.com";
public $Mailer = "smtp";
public $WordWrap = 75;
public $Port = "465";
public $SMTPAuth = true;
public function __construct($debug = false){
$this->Sender = $this->From;
$this->Username = $this->From;
$this->SMTPDebug = $debug;
}
}
$mail = new gMailer(false); //change to true if you are having trouble
$mail->AddAddress('xxxxxxxxxxx@gmail.com', 'addressee name');
$mail->Body = "This is a test message";
$mail->Subject = "Test Message";
if ($mail->send()) {echo "mail sent";}
else{echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;};