Overview

Namespaces

  • Jyxo
    • Beholder
      • TestCase
    • Gettext
      • Parser
    • Input
      • Chain
      • Filter
      • Validator
    • Mail
      • Email
        • Attachment
      • Parser
      • Sender
    • Rpc
      • Json
      • Xml
    • Shell
    • Spl
    • Svn
    • Time
    • Webdav
  • PHP

Classes

  • Email
  • Encoding
  • Parser
  • Sender
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  1: <?php
  2: 
  3: /**
  4:  * Jyxo PHP Library
  5:  *
  6:  * LICENSE
  7:  *
  8:  * This source file is subject to the new BSD license that is bundled
  9:  * with this package in the file license.txt.
 10:  * It is also available through the world-wide-web at this URL:
 11:  * https://github.com/jyxo/php/blob/master/license.txt
 12:  */
 13: 
 14: namespace Jyxo\Mail;
 15: 
 16: /**
 17:  * Email contents container.
 18:  *
 19:  * @category Jyxo
 20:  * @package Jyxo\Mail
 21:  * @subpackage Email
 22:  * @copyright Copyright (c) 2005-2011 Jyxo, s.r.o.
 23:  * @license https://github.com/jyxo/php/blob/master/license.txt
 24:  * @author Jaroslav HanslĂ­k
 25:  */
 26: class Email extends \Jyxo\Spl\Object
 27: {
 28:     /**
 29:      * Highest priority.
 30:      *
 31:      * @var integer
 32:      */
 33:     const PRIORITY_HIGHEST = 1;
 34: 
 35:     /**
 36:      * High priority.
 37:      *
 38:      * @var integer
 39:      */
 40:     const PRIORITY_HIGH = 2;
 41: 
 42:     /**
 43:      * Normal priority.
 44:      *
 45:      * @var integer
 46:      */
 47:     const PRIORITY_NORMAL = 3;
 48: 
 49:     /**
 50:      * Low priority.
 51:      *
 52:      * @var integer
 53:      */
 54:     const PRIORITY_LOW = 4;
 55: 
 56:     /**
 57:      * Lowest priority.
 58:      *
 59:      * @var integer
 60:      */
 61:     const PRIORITY_LOWEST = 5;
 62: 
 63:     /**
 64:      * Subject.
 65:      *
 66:      * @var string
 67:      */
 68:     private $subject = '';
 69: 
 70:     /**
 71:      * Email sender.
 72:      *
 73:      * @var \Jyxo\Mail\Email\Address
 74:      */
 75:     private $from = null;
 76: 
 77:     /**
 78:      * List of recipients.
 79:      *
 80:      * @var array
 81:      */
 82:     private $to = array();
 83: 
 84:     /**
 85:      * List of carbon copy recipients.
 86:      *
 87:      * @var array
 88:      */
 89:     private $cc = array();
 90: 
 91:     /**
 92:      * List of blind carbon copy recipients.
 93:      *
 94:      * @var array
 95:      */
 96:     private $bcc = array();
 97: 
 98:     /**
 99:      * Response recipient address.
100:      *
101:      * @var array
102:      */
103:     private $replyTo = array();
104: 
105:     /**
106:      * Reading confirmation recipient.
107:      *
108:      * @var \Jyxo\Mail\Email\Address
109:      */
110:     private $confirmReadingTo = null;
111: 
112:     /**
113:      * Id of the message this is a response to.
114:      *
115:      * @var string
116:      */
117:     private $inReplyTo = '';
118: 
119:     /**
120:      * References to previous messages in the thread.
121:      *
122:      * @var array
123:      */
124:     private $references = array();
125: 
126:     /**
127:      * Message priority.
128:      *
129:      * @var integer
130:      */
131:     private $priority = 0;
132: 
133:     /**
134:      * List of custom headers.
135:      *
136:      * @var array
137:      */
138:     private $headers = array();
139: 
140:     /**
141:      * Message body.
142:      *
143:      * @var \Jyxo\Mail\Email\Body
144:      */
145:     private $body = null;
146: 
147:     /**
148:      * List of attachments.
149:      *
150:      * @var array
151:      */
152:     private $attachments = array();
153: 
154:     /**
155:      * Returns subject.
156:      *
157:      * @return string
158:      */
159:     public function getSubject()
160:     {
161:         return $this->subject;
162:     }
163: 
164:     /**
165:      * Sets subject.
166:      *
167:      * @param string $subject Subject
168:      * @return \Jyxo\Mail\Email
169:      */
170:     public function setSubject($subject)
171:     {
172:         $this->subject = (string) $subject;
173: 
174:         return $this;
175:     }
176: 
177:     /**
178:      * Returns sender address.
179:      *
180:      * @return \Jyxo\Mail\Email\Address
181:      */
182:     public function getFrom()
183:     {
184:         return $this->from;
185:     }
186: 
187:     /**
188:      * Sets sender address.
189:      *
190:      * @param \Jyxo\Mail\Email\Address $from Message sender
191:      * @return \Jyxo\Mail\Email
192:      */
193:     public function setFrom(\Jyxo\Mail\Email\Address $from)
194:     {
195:         $this->from = $from;
196: 
197:         return $this;
198:     }
199: 
200:     /**
201:      * Returns list of message recipients.
202:      *
203:      * @return array
204:      */
205:     public function getTo()
206:     {
207:         return $this->to;
208:     }
209: 
210:     /**
211:      * Adds a recipient.
212:      *
213:      * @param \Jyxo\Mail\Email\Address $to New recipient
214:      * @return \Jyxo\Mail\Email
215:      */
216:     public function addTo(\Jyxo\Mail\Email\Address $to)
217:     {
218:         $this->to[] = $to;
219: 
220:         return $this;
221:     }
222: 
223:     /**
224:      * Returns list of carbon copy recipients.
225:      *
226:      * @return array
227:      */
228:     public function getCc()
229:     {
230:         return $this->cc;
231:     }
232: 
233:     /**
234:      * Adds a carbon copy recipient.
235:      *
236:      * @param \Jyxo\Mail\Email\Address $cc New recipient
237:      * @return \Jyxo\Mail\Email
238:      */
239:     public function addCc(\Jyxo\Mail\Email\Address $cc)
240:     {
241:         $this->cc[] = $cc;
242: 
243:         return $this;
244:     }
245: 
246:     /**
247:      * Returns list of blind carbon copy recipients.
248:      *
249:      * @return array
250:      */
251:     public function getBcc()
252:     {
253:         return $this->bcc;
254:     }
255: 
256:     /**
257:      * Adds a blind carbon copy recipient.
258:      *
259:      * @param \Jyxo\Mail\Email\Address $bcc New recipient
260:      * @return \Jyxo\Mail\Email
261:      */
262:     public function addBcc(\Jyxo\Mail\Email\Address $bcc)
263:     {
264:         $this->bcc[] = $bcc;
265: 
266:         return $this;
267:     }
268: 
269:     /**
270:      * Returns the 'ReplyTo' address.
271:      *
272:      * @return array
273:      */
274:     public function getReplyTo()
275:     {
276:         return $this->replyTo;
277:     }
278: 
279:     /**
280:      * Adds a 'ReplyTo' address.
281:      *
282:      * @param \Jyxo\Mail\Email\Address $replyTo
283:      * @return \Jyxo\Mail\Email
284:      */
285:     public function addReplyTo(\Jyxo\Mail\Email\Address $replyTo)
286:     {
287:         $this->replyTo[] = $replyTo;
288: 
289:         return $this;
290:     }
291: 
292:     /**
293:      * Returns a reading confirmation address.
294:      *
295:      * @return array
296:      */
297:     public function getConfirmReadingTo()
298:     {
299:         return $this->confirmReadingTo;
300:     }
301: 
302:     /**
303:      * Sets a reading confirmation address.
304:      *
305:      * @param \Jyxo\Mail\Email\Address $confirmReadingTo Confirmation recipient
306:      * @return \Jyxo\Mail\Email
307:      */
308:     public function setConfirmReadingTo(\Jyxo\Mail\Email\Address $confirmReadingTo)
309:     {
310:         $this->confirmReadingTo = $confirmReadingTo;
311: 
312:         return $this;
313:     }
314: 
315:     /**
316:      * Sets Id of the message this is a response to.
317:      *
318:      * @param string $inReplyTo Message Id
319:      * @param array $references Previous mail references
320:      * @return \Jyxo\Mail\Email
321:      */
322:     public function setInReplyTo($inReplyTo, array $references = array())
323:     {
324:         $this->inReplyTo = (string) $inReplyTo;
325:         $this->references = $references;
326: 
327:         return $this;
328:     }
329: 
330:     /**
331:      * Returns Id of the message this is a response to.
332:      *
333:      * @return string
334:      */
335:     public function getInReplyTo()
336:     {
337:         return $this->inReplyTo;
338:     }
339: 
340:     /**
341:      * Returns references to previous messages in the thread.
342:      *
343:      * @return array
344:      */
345:     public function getReferences()
346:     {
347:         return $this->references;
348:     }
349: 
350:     /**
351:      * Returns message priority.
352:      *
353:      * @return integer
354:      */
355:     public function getPriority()
356:     {
357:         return $this->priority;
358:     }
359: 
360:     /**
361:      * Sets message priority.
362:      *
363:      * @param integer $priority Priority
364:      * @return \Jyxo\Mail\Email
365:      * @throws \InvalidArgumentException If an unknown priority was provided
366:      */
367:     public function setPriority($priority)
368:     {
369:         static $priorities = array(
370:             self::PRIORITY_HIGHEST => true,
371:             self::PRIORITY_HIGH => true,
372:             self::PRIORITY_NORMAL => true,
373:             self::PRIORITY_LOW => true,
374:             self::PRIORITY_LOWEST => true
375:         );
376:         if (!isset($priorities[$priority])) {
377:             throw new \InvalidArgumentException(sprintf('Unknown priority %s', $priority));
378:         }
379: 
380:         $this->priority = (int) $priority;
381: 
382:         return $this;
383:     }
384: 
385:     /**
386:      * Returns custom headers.
387:      *
388:      * @return array
389:      */
390:     public function getHeaders()
391:     {
392:         return $this->headers;
393:     }
394: 
395:     /**
396:      * Adds a custom header.
397:      *
398:      * @param \Jyxo\Mail\Email\Header $header Header
399:      * @return \Jyxo\Mail\Email
400:      */
401:     public function addHeader(\Jyxo\Mail\Email\Header $header)
402:     {
403:         $this->headers[] = $header;
404: 
405:         return $this;
406:     }
407: 
408:     /**
409:      * Returns message body.
410:      *
411:      * @return \Jyxo\Mail\Email\Body
412:      */
413:     public function getBody()
414:     {
415:         return $this->body;
416:     }
417: 
418:     /**
419:      * Sets message body.
420:      *
421:      * @param \Jyxo\Mail\Email\Body $body Body
422:      * @return \Jyxo\Mail\Email
423:      */
424:     public function setBody(\Jyxo\Mail\Email\Body $body)
425:     {
426:         $this->body = $body;
427: 
428:         return $this;
429:     }
430: 
431:     /**
432:      * Returns attachments.
433:      *
434:      * @return array
435:      */
436:     public function getAttachments()
437:     {
438:         return $this->attachments;
439:     }
440: 
441:     /**
442:      * Adds an attachment.
443:      *
444:      * @param \Jyxo\Mail\Email\Attachment $attachment Attachment
445:      * @return \Jyxo\Mail\Email
446:      */
447:     public function addAttachment(\Jyxo\Mail\Email\Attachment $attachment)
448:     {
449:         $this->attachments[] = $attachment;
450: 
451:         return $this;
452:     }
453: 
454:     /**
455:      * Checks if the message contains any attachments.
456:      *
457:      * @return boolean
458:      */
459:     public function hasInlineAttachments()
460:     {
461:         foreach ($this->attachments as $attachment) {
462:             if ($attachment->isInline()) {
463:                 return true;
464:             }
465:         }
466: 
467:         return false;
468:     }
469: }
470: 
Jyxo PHP Library API documentation generated by ApiGen 2.3.0