Klenwell GmailMailer
click here to report bugs∞
GmailMailer is an extension of
PHPMailer∞ for use with
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
the repository∞.
Caution
Google policy does not allow "third party software that automatically logs in to your account". For more info,
click here∞
Configure
GmailMailer does not come packaged with PHPMailer. That can be
downloaded here∞. GmailMailer calls the file for the PHPMailer base class around line 65:
// *** 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
test script∞. Username and Password below would be your gmail email address (e.g. klenwell@gmail.com) and password.
// 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
There are no comments on this page. [Add comment]