]> git.wh0rd.org - tt-rss.git/blobdiff - plugins/mail/init.php
remove PHPMailer and related directives from config.php-dist; add pluggable Mailer...
[tt-rss.git] / plugins / mail / init.php
index 7da87ed575b5610a184eda96385948d91a5ab86d..1b31a220b06b82aa828fa23e0300709ceb6e57df 100644 (file)
@@ -86,7 +86,7 @@ class Mail extends Plugin {
                print_hidden("method", "sendEmail");
 
                $sth = $this->pdo->prepare("SELECT email, full_name FROM ttrss_users WHERE
-                       id = ?";
+                       id = ?");
                $sth->execute([$_SESSION['uid']]);
 
                if ($row = $sth->fetch()) {
@@ -168,7 +168,7 @@ class Mail extends Plugin {
 
                print "</td></tr>";
 
-               print "<tr><td colspan='2'><textarea dojoType=\"dijit.form.SimpleTextarea\" 
+               print "<tr><td colspan='2'><textarea dojoType=\"dijit.form.SimpleTextarea\"
                        style='height : 200px; font-size : 12px; width : 98%' rows=\"20\"
                        name='content'>$content</textarea>";
 
@@ -183,13 +183,9 @@ class Mail extends Plugin {
        }
 
        function sendEmail() {
-               require_once 'classes/ttrssmailer.php';
-
                $reply = array();
 
-               $mail = new ttrssMailer();
-
-               $mail->AddReplyTo(strip_tags($_REQUEST['from_email']),
+               /*$mail->AddReplyTo(strip_tags($_REQUEST['from_email']),
                        strip_tags($_REQUEST['from_name']));
                //$mail->AddAddress($_REQUEST['destination']);
                $addresses = explode(';', $_REQUEST['destination']);
@@ -200,10 +196,22 @@ class Mail extends Plugin {
                $mail->Subject = $_REQUEST['subject'];
                $mail->Body = $_REQUEST['content'];
 
-               $rc = $mail->Send();
+               $rc = $mail->Send(); */
+
+               $to = $_REQUEST["destination"];
+               $subject = strip_tags($_REQUEST["subject"]);
+               $message = strip_tags($_REQUEST["content"]);
+               $from = strip_tags($_REQUEST["from_email"]);
+
+               $mailer = new Mailer();
+
+               $mailer->mail(["to" => $to,
+                       "headers" => ["Reply-To: $from"],
+                       "subject" => $subject,
+                       "message" => $message]);
 
                if (!$rc) {
-                       $reply['error'] =  $mail->ErrorInfo;
+                       $reply['error'] =  $mailer->error();
                } else {
                        //save_email_address($destination);
                        $reply['message'] = "UPDATE_COUNTERS";
@@ -230,4 +238,4 @@ class Mail extends Plugin {
                return 2;
        }
 
-}
\ No newline at end of file
+}