예제 #1
0
 /**
  * Prepares the recipient email addresses.
  *
  * @return array
  */
 protected function _prepareRecipientAddresses()
 {
     $to = $this->_cakeEmail->to();
     $cc = $this->_cakeEmail->cc();
     $bcc = $this->_cakeEmail->bcc();
     return array_merge(array_keys($to), array_keys($cc), array_keys($bcc));
 }
예제 #2
0
 /**
  * TestSend method
  *
  * @return void
  */
 public function testSendWithEmail()
 {
     $Email = new Email();
     $Email->from('*****@*****.**', 'CakePHP Test');
     $Email->to('*****@*****.**', 'CakePHP');
     $Email->cc(['*****@*****.**' => 'Mark Story', '*****@*****.**' => 'Juan Basso']);
     $Email->bcc('*****@*****.**');
     $Email->subject('Testing Message');
     $Email->transport('queue');
     $config = $Email->config('default');
     $this->QueueTransport->config($config);
     $result = $this->QueueTransport->send($Email);
     $this->assertEquals('Email', $result['jobtype']);
     $this->assertTrue(strlen($result['data']) < 10000);
     $output = unserialize($result['data']);
     //debug($output);
     //$this->assertEquals($Email, $output['settings']);
 }
 public function sendMail($to, $subject, $from, $message, $attachments = null, $emailCofig = 'default', $emailtemplate = 'default', $formate = 'html', $replyto = null, $cc = null, $bcc = null)
 {
     $email = new Email('default');
     $email->emailFormat($formate);
     $email->from(array($from => Configure::read('FROM_EMAIL_NAME')));
     $email->to($to);
     $email->cc($cc);
     $email->bcc($bcc);
     $email->replyTo($replyto);
     $email->subject($subject);
     $email->template($emailtemplate, 'default');
     //        $email->attachments($attachments);
     if ($email->send($message)) {
         return true;
     } else {
         return false;
     }
 }
예제 #4
0
 /**
  * @param mixed $charset
  * @param mixed $headerCharset
  * @return CakeEmail
  */
 protected function _getEmailByNewStyleCharset($charset, $headerCharset)
 {
     $email = new Email(array('transport' => 'debug'));
     if (!empty($charset)) {
         $email->charset($charset);
     }
     if (!empty($headerCharset)) {
         $email->headerCharset($headerCharset);
     }
     $email->from('*****@*****.**', 'どこかの誰か');
     $email->to('*****@*****.**', 'どこかのどなたか');
     $email->cc('*****@*****.**', 'ミク');
     $email->subject('テストメール');
     $email->send('テストメールの本文');
     return $email;
 }
예제 #5
0
 /**
  * testRcpt method
  *
  * @return void
  */
 public function testRcpt()
 {
     $email = new Email();
     $email->from('*****@*****.**', 'CakePHP Test');
     $email->to('*****@*****.**', 'CakePHP');
     $email->bcc('*****@*****.**');
     $email->cc(array('*****@*****.**' => 'Mark Story', '*****@*****.**' => 'Juan Basso'));
     $this->socket->expects($this->at(0))->method('write')->with("MAIL FROM:<*****@*****.**>\r\n");
     $this->socket->expects($this->at(1))->method('read')->will($this->returnValue(false));
     $this->socket->expects($this->at(2))->method('read')->will($this->returnValue("250 OK\r\n"));
     $this->socket->expects($this->at(3))->method('write')->with("RCPT TO:<*****@*****.**>\r\n");
     $this->socket->expects($this->at(4))->method('read')->will($this->returnValue(false));
     $this->socket->expects($this->at(5))->method('read')->will($this->returnValue("250 OK\r\n"));
     $this->socket->expects($this->at(6))->method('write')->with("RCPT TO:<*****@*****.**>\r\n");
     $this->socket->expects($this->at(7))->method('read')->will($this->returnValue(false));
     $this->socket->expects($this->at(8))->method('read')->will($this->returnValue("250 OK\r\n"));
     $this->socket->expects($this->at(9))->method('write')->with("RCPT TO:<*****@*****.**>\r\n");
     $this->socket->expects($this->at(10))->method('read')->will($this->returnValue(false));
     $this->socket->expects($this->at(11))->method('read')->will($this->returnValue("250 OK\r\n"));
     $this->socket->expects($this->at(12))->method('write')->with("RCPT TO:<*****@*****.**>\r\n");
     $this->socket->expects($this->at(13))->method('read')->will($this->returnValue(false));
     $this->socket->expects($this->at(14))->method('read')->will($this->returnValue("250 OK\r\n"));
     $this->SmtpTransport->setEmail($email);
     $this->SmtpTransport->sendRcpt();
 }