12 require_once (CH_DIRECTORY_PATH_PLUGINS .
"phpmailer/class.phpmailer.php");
13 require_once (CH_DIRECTORY_PATH_PLUGINS .
"phpmailer/class.smtp.php");
22 function serviceSend ($sRecipientEmail, $sMailSubject, $sMailBody, $sMailHeader, $sMailParameters, $isHtml, $aRecipientInfo = array())
26 if ($sRecipientEmail) {
34 $mail->CharSet =
'utf8';
37 $mail->SMTPAuth =
'on' ==
getParam(
'ch_smtp_auth') ?
true :
false;
40 $sParamSecure =
getParam(
'ch_smtp_secure');
41 if (
'SSL' == $sParamSecure ||
'TLS' == $sParamSecure) {
42 $mail->SMTPSecure = strtolower($sParamSecure);
44 if (
'on' ==
getParam(
'ch_smtp_allow_selfsigned')) {
45 $mail->SMTPOptions = array(
47 'verify_peer' =>
false,
48 'verify_peer_name' =>
false,
49 'allow_self_signed' =>
true
56 $sParamHost =
getParam(
'ch_smtp_host');
58 $mail->Host = $sParamHost;
61 $sParamPort =
getParam(
'ch_smtp_port');
62 if ((
int)$sParamPort > 0)
63 $mail->Port = $sParamPort;
66 $mail->Username =
getParam (
'ch_smtp_username');
67 $mail->Password =
getParam (
'ch_smtp_password');
69 $sParamSender = trim(
getParam(
'ch_smtp_from_email'));
71 $mail->From = $sParamSender;
73 $mail->From = $sSenderEmail;
76 $mail->FromName =
getParam (
'ch_smtp_from_name');
78 $mail->Subject = $sMailSubject;
80 $mail->Body = $sMailBody;
81 $mail->AltBody = $isHtml ? strip_tags($sMailBody) : $sMailBody;
83 $mail->Body = $sMailBody;
88 $mail->AddAddress($sRecipientEmail);
91 if (
'on' ==
getParam (
'ch_smtp_send_attachments')) {
92 if ($h = opendir(CH_DIRECTORY_PATH_MODULES .
"cheetah/smtpmailer/data/attach/")) {
93 while (
false !== (
$sFile = readdir($h))) {
95 $mail->AddAttachment(CH_DIRECTORY_PATH_MODULES .
"cheetah/smtpmailer/data/attach/" .
$sFile,
$sFile);
101 $mail->IsHTML($isHtml ?
true :
false);
103 $iRet = $mail->Send();
105 $this->
log(
"Mailer Error ($sRecipientEmail): " . $mail->ErrorInfo);
112 'email' => $sRecipientEmail,
113 'subject' => $sMailSubject,
114 'body' => $sMailBody,
115 'header' => $sMailHeader,
116 'params' => $sMailParameters,
120 $oZ =
new ChWsbAlerts(
'profile',
'send_mail', $aRecipientInfo ? $aRecipientInfo[
'ID'] : 0,
'', $aAlertData);
130 $this->_oTemplate->displayAccessDenied ();
134 $this->_oTemplate->pageStart();
136 $iId = $this->_oDb->getSettingsCategory();
138 echo
MsgBox(
_t(
'_sys_request_page_not_found_cpt'));
139 $this->_oTemplate->pageCodeAdmin (
_t(
'_ch_smtp_administration'));
146 if(isset($_POST[
'save']) && isset($_POST[
'cat'])) {
148 $mixedResult =
$oSettings->saveChanges($_POST);
154 if($mixedResult !==
true && !
empty($mixedResult))
160 echo $this->_oTemplate->adminBlock ($this->_oTemplate->parseHtmlByName(
'default_padding',
$aVars),
_t(
'_ch_smtp_administration'));
163 'content' =>
_t(
'_ch_smtp_help_text')
165 echo $this->_oTemplate->adminBlock ($this->_oTemplate->parseHtmlByName(
'default_padding',
$aVars),
_t(
'_ch_smtp_help'));
170 echo $this->_oTemplate->adminBlock ($this->_oTemplate->parseHtmlByName(
'default_padding',
$aVars),
_t(
'_ch_smtp_tester'));
172 $this->_oTemplate->addCssAdmin (
'forms_adv.css');
173 $this->_oTemplate->pageCodeAdmin (
_t(
'_ch_smtp_administration'));
179 if ($_POST[
'tester_submit']) {
184 $isHTML = $_POST[
'html'] ==
'on' ?
true :
false;
186 if (
sendMail($sRecipient, $sSubj, $sBody, 0, array(), $isHTML ?
'html' :
''))
193 'form_attrs' => array(
194 'action' => CH_WSB_URL_ROOT . $this->_oConfig->getBaseUri() .
'administration/',
199 'type' =>
'block_header',
200 'caption' =>
_t(
'_ch_smtp_tester'),
202 'recipient' => array(
204 'name' =>
'recipient',
205 'caption' =>
_t(
'_ch_smtp_recipient'),
211 'caption' =>
_t(
'_ch_smtp_subject'),
215 'type' =>
'textarea',
217 'caption' =>
_t(
'_ch_smtp_body'),
221 'type' =>
'checkbox',
223 'caption' =>
_t(
'_ch_smtp_is_html'),
228 'name' =>
'tester_submit',
229 'value' =>
_t(
"_Submit"),
246 $fn = CH_DIRECTORY_PATH_MODULES .
"cheetah/smtpmailer/data/logs/log.log";
247 $f = @fopen ($fn,
'a');
249 fwrite (
$f, date(DATE_RFC822) .
"\t" .
$s .
"\n");