forked from leonardoxc/leonardoxc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CL_mail.php
64 lines (55 loc) · 2.13 KB
/
CL_mail.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?
//************************************************************************
// Leonardo XC Server, http://www.leonardoxc.net
//
// Copyright (c) 2004-2010 by Andreadakis Manolis
//
// This program is free software. You can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License.
//
// $Id: CL_mail.php,v 1.6 2010/11/22 14:28:48 manolis Exp $
//
//************************************************************************
require_once dirname(__FILE__)."/lib/mail/class.phpmailer.php";
class LeonardoMail{
function sendMail($Subject,$Content,$toEmail,$toName,$fromMail='',$fromName='',$isHtml=false){
//echo " $Subject,$Content,$toEmail,$toName,$fromMail='',$fromName='' <BR>";
global $CONF,$CONF_admin_email;
if ($fromMail=='') $fromMail=$CONF_admin_email;
if ($fromName=='') $fromName=$CONF['site']['name'];
if ($CONF['mail']['method']!='smtp') { // use mail() function
$headers ="From: $fromMail";
if ($isHtml){
$headers.="\nContent-Type: text/html; charset=UTF-8\nContent-Transfer-Encoding: 8bit\n\n";
}
mail($toEmail,$Subject,$Content, $headers);
} else { // use an external mail server
$mail = new PHPMailer();
$mail->CharSet = "UTF-8";
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->Host = $CONF['mail']['smtp']['host']; // sets GMAIL as the SMTP server
if( $CONF['mail']['smtp']['ssl'] ){
$mail->SMTPSecure = "ssl";
}
$mail->Port = $CONF['mail']['smtp']['port']; // set the SMTP port
$mail->Username = $CONF['mail']['smtp']['username']; // GMAIL username
$mail->Password = $CONF['mail']['smtp']['password']; // GMAIL password
$mail->SMTPDebug = 0;
$mail->IsHTML($isHtml);
$mail->From = $fromMail;
$mail->FromName = $fromName;
$mail->Subject = $Subject." ";
$mail->Body = $Content;
$mail->AddAddress($toEmail, $toName);
if (!$mail->Send()) {
// echo "Problem sending mail : ".$mail->ErrorInfo."<BR>";
return false;
} else{
return true;
}
}
} // end of function
}
?>