LetoDMS Community Forum
Send mail notifications via Gmail - Printable Version

+- LetoDMS Community Forum (https://community.letodms.com)
+-- Forum: LetoDMS Support (https://community.letodms.com/forumdisplay.php?fid=4)
+--- Forum: General Questions (https://community.letodms.com/forumdisplay.php?fid=15)
+--- Thread: Send mail notifications via Gmail (/showthread.php?tid=430)



Send mail notifications via Gmail - ssrini - 01-08-2012

I require to also send out mail notifications via Gmail/Google Apps. The mail settings today do not permit that. Any easy ways this can be achieved?

Thanks
Srini


RE: Send mail notifications via Gmail - hugo13 - 02-24-2012

download PHPMailer from http://code.google.com/a/apache-extras.org/p/phpmailer/downloads/list and add a folder called PHPMailer in the docRootOfLetoDMS

I changed file inc/inc.ClassEmail.php

add after line 19
PHP Code:
<?php 
require_once('../PHPMailer/class.phpmailer.php');

in the class I added

PHP Code:
<?php 
function mail($recipient, $subject, $message, $header){
$recList = split(',', $recipient);
$mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch
$mail->IsSMTP(); // telling the class to use SMTP
try {
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port for the GMAIL server
$mail->Username = "rainer@example.com"; // GMAIL username
$mail->Password = "password"; // GMAIL password
$mail->AddReplyTo('barbara@example.net', 'ReplyToMe');
foreach (
$recList as $value) {
$mail->AddAddress($value, $value);
}
$mail->SetFrom('barbara@example.net', 'myDMS');
$mail->Subject = $subject;
$mail->Body = $message;
$mail->Send();
} catch (
phpmailerException $e) {
echo
$e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
echo
$e->getMessage(); //Boring error messages from anything else!
}
}

lines like
PHP Code:
<?php 
return (mail($recipient->getEmail(), $this->replaceMarker($subject), $this->replaceMarker($message), $header) ? 0 : -1);
changed to
PHP Code:
<?php 
return ($this->mail($recipient->getEmail(), $this->replaceMarker($subject), $this->replaceMarker($message), $header) ? 0 : -1);

have fun
rainer