/** * Send the mail * * @param CCMail $mail The mail object. * @return void * * @throws Mail\Exception */ public function send(CCMail $mail) { // create new phpmailer instance $driver = new PHPMailer\PHPMailer(); // set the charset $driver->CharSet = 'utf-8'; // set the xmailer tag $driver->XMailer = "ClanCatsFramework 2.0 Mail / PHPMailer " . $driver->Version; // get the mail data as array $mail_data = $mail->export_data(); // from address and name list($from_email, $from_name) = $mail_data['from']; $driver->From = $from_email; if (!is_null($from_name)) { $driver->FromName = $from_name; } // set the recipients foreach ($mail_data['to'] as $email => $name) { $driver->AddAddress($email, $name); } // set bcc foreach ($mail_data['bcc'] as $email => $name) { $driver->addBCC($email, $name); } // set cc foreach ($mail_data['cc'] as $email => $name) { $driver->addCC($email, $name); } // add attachments foreach ($mail_data['attachments'] as $path => $name) { $driver->addAttachment($path, $name); } // set the subject $driver->Subject = $mail_data['subject']; // set the message $driver->Body = $mail_data['message']; $driver->AltBody = $mail_data['plaintext']; $driver->IsHTML(!$mail_data['is_plaintext']); // setup the driver $this->setup_driver($driver); if (!$driver->Send()) { throw new Exception("Mail failure: " . $driver->ErrorInfo); } }
/** * Send the mail * * @param CCMail $mail The mail object. * @return void * * @throws Mail\Exception */ public function send(CCMail $mail) { $data = $mail->export_data(); $filename = 'mails/' . date('Y-m') . '/' . date('d') . '/' . date("H-i-s") . '-' . \CCStr::clean_url($data['subject']) . '.log'; \CCFile::append(\CCStorage::path($filename), \CCJson::encode($data, true)); }
/** * CCMail::is_plaintext tests */ public function test_is_plaintext() { $mail = CCMail::create(); $mail->to('*****@*****.**'); $mail->is_plaintext(); $mail->send(); $mail_data = CCArr::last(Mail\Transporter_Array::$store); $this->assertEquals(true, $mail_data['is_plaintext']); }
/** * Send the mail * * @param CCMail $mail The mail object. * @return void * * @throws Mail\Exception */ public function send(CCMail $mail) { static::$store[] = $mail->export_data(); }