Swift_Message::__construct PHP Method

__construct() public method

Details may be optionally passed into the constructor.
public __construct ( string $subject = null, string $body = null, string $contentType = null, string $charset = null )
$subject string
$body string
$contentType string
$charset string
    public function __construct($subject = null, $body = null, $contentType = null, $charset = null)
    {
        call_user_func_array(array($this, 'Swift_Mime_SimpleMessage::__construct'), Swift_DependencyContainer::getInstance()->createDependenciesFor('mime.message'));
        if (!isset($charset)) {
            $charset = Swift_DependencyContainer::getInstance()->lookup('properties.charset');
        }
        $this->setSubject($subject);
        $this->setBody($body);
        $this->setCharset($charset);
        if ($contentType) {
            $this->setContentType($contentType);
        }
    }

Usage Example

    /**
     * Construct.
     *
     * @param string $message
     * @param string $reference
     */
    public function __construct($message, $reference)
    {
        parent::__construct();
        $body = <<<EOF
An error occurred while trying to send email: {$reference}
{$message}
EOF;
        $this->setSubject('An exception occurred')->setBody($body);
    }
All Usage Examples Of Swift_Message::__construct