/** * Constructor. Note that the fourth argument is treated as a file name, * not content to be attached. To attach data without using a file, * instantiate the object with just the first three parameters and call * the $this->setAttachmentContent() method to attach the data. * * @param string $to * @param string $subject = null * @param string $message = null * @param string $attachment = null * @param string $attachmentFilename = null */ public function __construct($to, $subject = null, $message = null, $attachment = null, $attachmentFilename = null) { if (!self::$_DEFAULT_FROM_HOSTNAME) { self::_setDefaults(); /* We want to call some setters in order to ensure that the setting values add up to usable properties, but we don't want to do it on this instance, or we will get an odd situation where the first Email instance in a process will have certain property values that any remaining instances won't have. We'll do it on a dummy instance that won't outlive this scope. */ $dummy = new self('*****@*****.**'); $dummy->setFromName(self::$_DEFAULT_FROM_NAME); $dummy->setFromAddress(self::$_DEFAULT_FROM_USER . '@' . self::$_DEFAULT_FROM_HOSTNAME); $dummy->setReplyToAddress(self::$_DEFAULT_REPLY_TO); } $this->_to = self::$_validator->email($to, 'Invalid email address.', Validator::ASSERT_TRUTH); $this->setSubject($subject); $this->setMessage($message); if ($attachment) { $this->addAttachment($attachment, $attachmentFilename); } }