Overview

Packages

  • Jyxo_Beholder
  • Jyxo_Charset
  • Jyxo_Color
  • Jyxo_Css
  • Jyxo_ErrorHandling
  • Jyxo_FirePhp
  • Jyxo_Gettext
    • Parser
  • Jyxo_Html
  • Jyxo_Input
    • Chain
    • Filter
    • Validator
  • Jyxo_Mail
    • Email
    • Parser
    • Sender
  • Jyxo_Rpc
    • Json
    • Xml
  • Jyxo_Shell
  • Jyxo_SpamFilter
  • Jyxo_Spl
  • Jyxo_String
  • Jyxo_Svn
  • Jyxo_Time
  • Jyxo_Timer
  • Jyxo_Webdav
  • Jyxo_XmlReader
  • PHP

Classes

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