From 31a53903e635ae84ae1551d52772e75f2380b416 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 6 Nov 2010 00:47:02 +0300 Subject: add article forwarding by email (closes #271) --- modules/backend-rpc.php | 75 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) (limited to 'modules/backend-rpc.php') diff --git a/modules/backend-rpc.php b/modules/backend-rpc.php index 1645db96e..55babdaa7 100644 --- a/modules/backend-rpc.php +++ b/modules/backend-rpc.php @@ -1019,6 +1019,81 @@ return; } + if ($subop == "sendEmail") { + $secretkey = $_REQUEST['secretkey']; + + print ""; + + if (DIGEST_ENABLE && $_SESSION['email_secretkey'] && + $secretkey == $_SESSION['email_secretkey']) { + + $_SESSION['email_secretkey'] = ''; + + $destination = $_REQUEST['destination']; + $subject = $_REQUEST['subject']; + $content = $_REQUEST['content']; + + $replyto = strip_tags($_SESSION['email_replyto']); + $fromname = strip_tags($_SESSION['email_fromname']); + + $mail = new PHPMailer(); + + $mail->PluginDir = "lib/phpmailer/"; + $mail->SetLanguage("en", "lib/phpmailer/language/"); + + $mail->CharSet = "UTF-8"; + + $mail->From = $replyto; + $mail->FromName = $fromname; + $mail->AddAddress($destination); + + if (DIGEST_SMTP_HOST) { + $mail->Host = DIGEST_SMTP_HOST; + $mail->Mailer = "smtp"; + $mail->SMTPAuth = DIGEST_SMTP_LOGIN != ''; + $mail->Username = DIGEST_SMTP_LOGIN; + $mail->Password = DIGEST_SMTP_PASSWORD; + } + + $mail->IsHTML(false); + $mail->Subject = $subject; + $mail->Body = $content; + + $rc = $mail->Send(); + + if (!$rc) { + print "ErrorInfo . "]]>"; + } else { + save_email_address($link, db_escape_string($destination)); + print "OK"; + } + + } else { + print "Not authorized."; + } + + print ""; + + return; + } + + if ($subop == "completeEmails") { + + $search = db_escape_string($_REQUEST["search"]); + + print ""; + + return; + } + print "Unknown method: $subop"; } ?> -- cgit v1.2.3