/** * Send an email * * @param string $subject The subject of the email * @param string $body The body of the email to send * @param string $to The email address to send to * @return boolean */ protected function sendEmail($subject, $body, $to) { if (!$this->_loadLexicon()) { return false; } $this->xpdo->lexicon->load('quip:emails'); $this->xpdo->getService('mail', 'mail.modPHPMailer'); if (!$this->xpdo->mail) { return false; } $emailFrom = $this->xpdo->context->getOption('quip.emailsFrom', $this->xpdo->context->getOption('emailsender')); $emailReplyTo = $this->xpdo->context->getOption('quip.emailsReplyTo', $this->xpdo->context->getOption('emailsender')); /* allow multiple to addresses */ if (!is_array($to)) { $to = explode(',', $to); } $success = false; foreach ($to as $emailAddress) { if (empty($emailAddress) || strpos($emailAddress, '@') == false) { continue; } $this->xpdo->mail->set(modMail::MAIL_BODY, $body); $this->xpdo->mail->set(modMail::MAIL_FROM, $emailFrom); $this->xpdo->mail->set(modMail::MAIL_FROM_NAME, $this->xpdo->context->getOption('quip.emails_from_name', 'Quip')); $this->xpdo->mail->set(modMail::MAIL_SENDER, $emailFrom); $this->xpdo->mail->set(modMail::MAIL_SUBJECT, $subject); $this->xpdo->mail->address('to', $emailAddress); $this->xpdo->mail->address('reply-to', $emailReplyTo); $this->xpdo->mail->setHTML(true); $success = $this->xpdo->mail->send(); $this->xpdo->mail->reset(); } return $success; }
/** * Send an email to the user * * @param string $message The body of the email * @param array $options An array of options * @return boolean True if successful */ public function sendEmail($message, array $options = array()) { if (!$this->xpdo instanceof modX) { return false; } $profile = $this->getOne('Profile'); if (empty($profile)) { return false; } $this->xpdo->getService('mail', 'mail.modPHPMailer'); if (!$this->xpdo->mail) { return false; } $this->xpdo->mail->set(modMail::MAIL_BODY, $message); $this->xpdo->mail->set(modMail::MAIL_FROM, $this->xpdo->getOption('from', $options, $this->xpdo->getOption('emailsender'))); $this->xpdo->mail->set(modMail::MAIL_FROM_NAME, $this->xpdo->getOption('fromName', $options, $this->xpdo->getOption('site_name'))); $this->xpdo->mail->set(modMail::MAIL_SENDER, $this->xpdo->getOption('sender', $options, $this->xpdo->getOption('emailsender'))); $this->xpdo->mail->set(modMail::MAIL_SUBJECT, $this->xpdo->getOption('subject', $options, $this->xpdo->getOption('emailsubject'))); $this->xpdo->mail->address('to', $profile->get('email'), $profile->get('fullname')); $this->xpdo->mail->address('reply-to', $this->xpdo->getOption('sender', $options, $this->xpdo->getOption('emailsender'))); $this->xpdo->mail->setHTML($this->xpdo->getOption('html', $options, true)); $sent = $this->xpdo->mail->send(); $this->xpdo->mail->reset(); return $sent; }
/** * Get the client responsible for communicating with the provider. * * @return modRestClient|bool A REST client instance, or FALSE. */ public function getClient() { if (empty($this->xpdo->rest)) { $this->xpdo->getService('rest', 'rest.modRestClient'); $loaded = $this->xpdo->rest->getConnection(); if (!$loaded) { return false; } } return $this->xpdo->rest; }