Example #1
0
 public static function fromArray(array $array)
 {
     $message = new self($array['subject']);
     if (null !== $array['sender']) {
         $message->setSender($array['sender']);
     }
     if (null !== $array['from']) {
         $message->setFrom($array['from']);
     }
     if (null !== $array['to']) {
         $message->setTo($array['to']);
     }
     if (null !== $array['replyTo']) {
         $message->setReplyTo($array['replyTo']);
     }
     if (null !== $array['cc']) {
         $message->setCc($array['cc']);
     }
     if (null !== $array['bcc']) {
         $message->setBcc($array['bcc']);
     }
     if (null !== $array['text']) {
         $message->setBodyWithAlternative($array['text'], $array['html']);
     }
     foreach ($array['customHeaders'] as $label => $valueList) {
         foreach ($valueList as $value) {
             $message->getHeaders()->addTextHeader($label, $value);
         }
     }
     return $message;
 }
 /**
  * Creates an email instance from a registration object.
  *
  * @param  EventRegistration $registration
  * @return EventRegistrationDetailsEmail
  */
 public static function factory(EventRegistration $registration)
 {
     $email = new self();
     $siteconfig = SiteConfig::current_site_config();
     $email->setTo($registration->Email);
     $email->setSubject(sprintf('Registration Details For %s (%s)', $registration->Time()->EventTitle(), $siteconfig->Title));
     $email->populateTemplate(array('Registration' => $registration, 'SiteConfig' => $siteconfig));
     if ($generator = $registration->Time()->Event()->TicketGenerator) {
         $generator = new $generator();
         $path = $generator->generateTicketFileFor($registration);
         $name = $generator->getTicketFilenameFor($registration);
         $mime = $generator->getTicketMimeTypeFor($registration);
         if ($path) {
             $email->attachFile($path, $name, $mime);
         }
     }
     singleton(get_class())->extend('updateEmail', $email, $registration);
     return $email;
 }
Example #3
0
 static function send($to, $subject, $msg, $attach = '', $attachFilename = '')
 {
     $e = new self();
     $e->setFrom(ini::get('email-address'), ini::get('email-name'));
     $e->setTo($to);
     $e->setSubject($subject);
     $e->setBody($msg);
     if (strlen($attach)) {
         $e->attach($attach, strlen($attachFilename) ? $attachFilename : 'attachment-1');
     }
     return $e->mail();
 }
Example #4
0
File: Mail.php Project: vakata/mail
 /**
  * Create an instance from a stringified mail.
  * @param  string     $str the mail string
  * @return \vakata\mail\Mail          the mail instance
  */
 public static function fromString($mail)
 {
     $rtrn = new self();
     $mail = $rtrn->parseParts($mail);
     foreach ($mail['head'] as $k => $v) {
         switch (strtolower($k)) {
             case 'to':
                 $rtrn->setTo($v);
                 break;
             case 'cc':
                 $rtrn->setCc($v);
                 break;
             case 'bcc':
                 $rtrn->setBcc($v);
                 break;
             case 'from':
                 $rtrn->setFrom($v);
                 break;
             case 'subject':
                 $rtrn->setSubject($v);
                 break;
             default:
                 $rtrn->setHeader($k, $v);
                 break;
         }
     }
     $rtrn->processPart($mail);
     return $rtrn;
 }
 /**
  * Creates a broker properties instance with specified JSON message.  
  *
  * @param string $brokerPropertiesJson A JSON message representing a 
  *                                     broker properties.
  * 
  * @return none
  */
 public static function create($brokerPropertiesJson)
 {
     Validate::isString($brokerPropertiesJson, 'brokerPropertiesJson');
     $brokerProperties = new self();
     $brokerPropertiesArray = (array) json_decode($brokerPropertiesJson);
     if (array_key_exists('CorrelationId', $brokerPropertiesArray)) {
         $brokerProperties->setCorrelationId($brokerPropertiesArray['CorrelationId']);
     }
     if (array_key_exists('SessionId', $brokerPropertiesArray)) {
         $brokerProperties->setSessionId($brokerPropertiesArray['SessionId']);
     }
     if (array_key_exists('DeliveryCount', $brokerPropertiesArray)) {
         $brokerProperties->setDeliveryCount($brokerPropertiesArray['DeliveryCount']);
     }
     if (array_key_exists('LockedUntilUtc', $brokerPropertiesArray)) {
         $brokerProperties->setLockedUntilUtc(\DateTime::createFromFormat(Resources::AZURE_DATE_FORMAT, $brokerPropertiesArray['LockedUntilUtc']));
     }
     if (array_key_exists('LockToken', $brokerPropertiesArray)) {
         $brokerProperties->setLockToken($brokerPropertiesArray['LockToken']);
     }
     if (array_key_exists('MessageId', $brokerPropertiesArray)) {
         $brokerProperties->setMessageId($brokerPropertiesArray['MessageId']);
     }
     if (array_key_exists('Label', $brokerPropertiesArray)) {
         $brokerProperties->setLabel($brokerPropertiesArray['Label']);
     }
     if (array_key_exists('ReplyTo', $brokerPropertiesArray)) {
         $brokerProperties->setReplyTo($brokerPropertiesArray['ReplyTo']);
     }
     if (array_key_exists('SequenceNumber', $brokerPropertiesArray)) {
         $brokerProperties->setSequenceNumber($brokerPropertiesArray['SequenceNumber']);
     }
     if (array_key_exists('TimeToLive', $brokerPropertiesArray)) {
         $brokerProperties->setTimeToLive(doubleval($brokerPropertiesArray['TimeToLive']));
     }
     if (array_key_exists('To', $brokerPropertiesArray)) {
         $brokerProperties->setTo($brokerPropertiesArray['To']);
     }
     if (array_key_exists('ScheduledEnqueueTimeUtc', $brokerPropertiesArray)) {
         $brokerProperties->setScheduledEnqueueTimeUtc(\DateTime::createFromFormat(Resources::AZURE_DATE_FORMAT, $brokerPropertiesArray['ScheduledEnqueueTimeUtc']));
     }
     if (array_key_exists('ReplyToSessionId', $brokerPropertiesArray)) {
         $brokerProperties->setReplyToSessionId($brokerPropertiesArray['ReplyToSessionId']);
     }
     if (array_key_exists('MessageLocation', $brokerPropertiesArray)) {
         $brokerProperties->setMessageLocation($brokerPropertiesArray['MessageLocation']);
     }
     if (array_key_exists('LockLocation', $brokerPropertiesArray)) {
         $brokerProperties->setLockLocation($brokerPropertiesArray['LockLocation']);
     }
     return $brokerProperties;
 }
Example #6
0
 protected static function fromStdClass($obj)
 {
     $ret = new self($obj->eventid);
     $ret->setTitle($obj->title);
     $ret->setDescripion($obj->desc);
     $ret->setFrom(\DateTime::createFromFormat('Y-m-d H:i:s', $obj->from, new \DateTimeZone("UTC")));
     $ret->setTo(\DateTime::createFromFormat('Y-m-d H:i:s', $obj->to, new \DateTimeZone("UTC")));
     $ret->getFrom()->setTimezone(new \DateTimeZone(get_option('timezone_string')));
     $ret->getTo()->setTimezone(new \DateTimeZone(get_option('timezone_string')));
     $ret->setPlace(Place::findById($obj->placeid));
     $ret->setPostId($obj->postid);
     return $ret;
 }
Example #7
0
 /**
  * Sets the Mail Headers
  * @param Object $result
  * @return self
  */
 public static function parseOverview($result)
 {
     $instance = new self();
     $instance->setSubject($result->subject);
     $instance->setFrom($result->from);
     $instance->setDate($result->date);
     $instance->setRead($result->seen);
     $instance->setMsgNo($result->msgno);
     $instance->setTo($result->to);
     return $instance;
 }