Wiki source for PhpGmailMailer
======Klenwell ""GmailMailer""======
===[[http://code.google.com/p/klenwell/downloads/list download here]]===
[[http://code.google.com/p/klenwell/issues/list click here to report bugs]]
""GmailMailer"" is an extension of [[http://phpmailer.sourceforge.net/ PHPMailer]] for use with [[https://mail.google.com/support/bin/answer.py?answer=13287&query=smtp&topic=&type=f&ctx=search Gmail accounts via smtp]]. Unlike the other solutions I've found to the problem of using ""PHPMailer"" with Gmail, ""GmailMailer"" -- by extending the ""PHPMailer"" class and overriding a couple function -- does not require any modification of the ""PHPMailer"" class itself.
It can be downloaded together with a test script from the klenwell code site. The source is available from [[http://klenwell.googlecode.com/svn/trunk/PHP/kw_gmailer/ the repository]].
===Caution===
Google policy does not allow "third party software that automatically logs in to your account". For more info, [[http://mail.google.com/support/bin/answer.py?answer=43692 click here]]
===Configure===
""GmailMailer"" does not come packaged with ""PHPMailer"". That can be [[http://phpmailer.sourceforge.net/ downloaded here]]. ""GmailMailer"" calls the file for the ""PHPMailer"" base class around line 65:
%%(php)
// *** IMPORTANT : set path to directory holding PHPMailer base class here
$__PHPMAILER['dirpath'] = '';
$__PHPMAILER['basename'] = 'class.phpmailer.php';
require_once($__PHPMAILER['dirpath'] . $__PHPMAILER['basename']);
%%
The simplest way to accomplish this is to drop ""GmailMailer"" in the same directory as ""PHPMailer"" and leave ""$__PHPMAILER['dirpath']"" blank. Otherwise, ""$__PHPMAILER['dirpath']"" should be pointed to the directory in which ""PHPMailer"" is found.
===Usage===
This is the same code from the [[http://klenwell.googlecode.com/svn/branches/archive2008/PHP/kw_gmailer/test.gmailer.php test script]]. Username and Password below would be your gmail email address (e.g. klenwell@gmail.com) and password.
%%(php)
// settings
$_PATH['gmailer'] = 'gmailer.class.php';
// run
require_once($_PATH['gmailer']);
$Mailer = new GmailMailer($debug=1);
$Mailer->Username = '';
$Mailer->Password = '';
$Mailer->FromName = 'Your Name';
$Mailer->AddAddress('recipient@gmail.com', 'Recipient Name');
$Mailer->Subject = 'testing GmailMailer';
$Mailer->Body = "This is a test of GmailMailer, an extension of PHPMailer for use with Gmail accounts.";
if ( !$Mailer->send_email() )
{
trigger_error('drats! It failed', E_USER_WARNING);
}
else
{
$Mailer->print_d('Message successfully sent!');
$Mailer->print_d("<pre><b>Subject:{$Mailer->Subject}</b>\n{$Mailer->Body}</pre>");
}
%%
----
CategoryGreqo
CategoryPhp
===[[http://code.google.com/p/klenwell/downloads/list download here]]===
[[http://code.google.com/p/klenwell/issues/list click here to report bugs]]
""GmailMailer"" is an extension of [[http://phpmailer.sourceforge.net/ PHPMailer]] for use with [[https://mail.google.com/support/bin/answer.py?answer=13287&query=smtp&topic=&type=f&ctx=search Gmail accounts via smtp]]. Unlike the other solutions I've found to the problem of using ""PHPMailer"" with Gmail, ""GmailMailer"" -- by extending the ""PHPMailer"" class and overriding a couple function -- does not require any modification of the ""PHPMailer"" class itself.
It can be downloaded together with a test script from the klenwell code site. The source is available from [[http://klenwell.googlecode.com/svn/trunk/PHP/kw_gmailer/ the repository]].
===Caution===
Google policy does not allow "third party software that automatically logs in to your account". For more info, [[http://mail.google.com/support/bin/answer.py?answer=43692 click here]]
===Configure===
""GmailMailer"" does not come packaged with ""PHPMailer"". That can be [[http://phpmailer.sourceforge.net/ downloaded here]]. ""GmailMailer"" calls the file for the ""PHPMailer"" base class around line 65:
%%(php)
// *** IMPORTANT : set path to directory holding PHPMailer base class here
$__PHPMAILER['dirpath'] = '';
$__PHPMAILER['basename'] = 'class.phpmailer.php';
require_once($__PHPMAILER['dirpath'] . $__PHPMAILER['basename']);
%%
The simplest way to accomplish this is to drop ""GmailMailer"" in the same directory as ""PHPMailer"" and leave ""$__PHPMAILER['dirpath']"" blank. Otherwise, ""$__PHPMAILER['dirpath']"" should be pointed to the directory in which ""PHPMailer"" is found.
===Usage===
This is the same code from the [[http://klenwell.googlecode.com/svn/branches/archive2008/PHP/kw_gmailer/test.gmailer.php test script]]. Username and Password below would be your gmail email address (e.g. klenwell@gmail.com) and password.
%%(php)
// settings
$_PATH['gmailer'] = 'gmailer.class.php';
// run
require_once($_PATH['gmailer']);
$Mailer = new GmailMailer($debug=1);
$Mailer->Username = '';
$Mailer->Password = '';
$Mailer->FromName = 'Your Name';
$Mailer->AddAddress('recipient@gmail.com', 'Recipient Name');
$Mailer->Subject = 'testing GmailMailer';
$Mailer->Body = "This is a test of GmailMailer, an extension of PHPMailer for use with Gmail accounts.";
if ( !$Mailer->send_email() )
{
trigger_error('drats! It failed', E_USER_WARNING);
}
else
{
$Mailer->print_d('Message successfully sent!');
$Mailer->print_d("<pre><b>Subject:{$Mailer->Subject}</b>\n{$Mailer->Body}</pre>");
}
%%
----
CategoryGreqo
CategoryPhp