/** * Send a posted contact request to the site admin. */ public function postSendMessage() { // Make sure the sender's email address is valid. if (!($sender_email = Request::post('email', 'email'))) { Messenger::error('Please enter a valid email address.'); return $this->get(); } if (!ReCaptcha::verify()) { Messenger::error('You did not correctly enter the captcha code.'); return $this->get(); } $subject = Configuration::get('contact.subject'); $body = "\nName: {$_POST['name']}\nEmail: {$sender_email}\nMessage:\n{$_POST['message']}"; $to_addresses = Configuration::get('contact.to'); $mailer = new Mailer(); foreach ($to_addresses as $to) { $mailer->to($to); } $sent = $mailer->from($sender_email)->subject($subject)->message($body)->send(); if (!$sent) { Messenger::error('Your message could not be sent. Please try again later'); return $this->get(); } else { // Send an email to to have them test for spam. if ($auto_responder = Configuration::get('contact.auto_responder')) { $auto_responder_mailer = new Mailer(); $result = $auto_responder_mailer->sendOne($auto_responder, UserModel::loadByEmail($sender_email) ?: new UserModel(array('email' => $sender_email))); if ($result && Configuration::get('contact.spam_test')) { // Set the notice. Navigation::redirect('/message', array('msg' => 'spam_test')); } } Navigation::redirect('/message', array('msg' => 'contact_sent')); } }
/** * Send a test email. */ public function postSendTest() { Output::disableBuffering(); Messenger::setVerbose(true); $mailer = new Mailer(true); $mailer->sendBulk(Request::get('id', 'int'), true); exit; }
public function execute($job) { $mailer = new MailerTool(); $date = new DateTime(); $time = $date->getTimestamp(); $start = $job['last_start'] + $date->getOffset(); $end = $time + $date->getOffset(); // Load all messages that should be sent on a specific date. $messages = Database::getInstance()->selectColumn('message', 'message_id', ['send_date' => ['BETWEEN', $start, $end]]); foreach ($messages as $message_id) { $start_time = time(); $this->out("Sending message {$message_id}"); $count = $mailer->sendBulk($message_id, false, true); $time = Time::formatLength(time() - $start_time); $this->out("Message {$message_id} sent to {$count} users in {$time}"); } }
/** * Send a confirmation email for the user to validate their email address. */ public function sendConfirmationEmail() { if (static::requiresConfirmation() && ($confirmation_message = Configuration::get('mailer.confirm_message'))) { $mailer = new Mailer(); $url = Configuration::get('web_root') . '/user?action=confirm&u=' . $this->getEncryptedUserReference(); $mailer->setCustomVariable('SUBSCRIPTION_CONFIRMATION_LINK', $url); $mailer->sendOne($confirmation_message, $this); } }