Class yii\swiftmailer\Message
Inheritance | yii\swiftmailer\Message » yii\mail\BaseMessage » yii\base\BaseObject |
---|---|
Implements | yii\base\Configurable, yii\mail\MessageInterface |
Available since version | 2.0 |
Source Code | https://github.com/yiisoft/yii2-swiftmailer/blob/master/Message.php |
Message implements a message class based on SwiftMailer.
See also:
Public Properties
Property | Type | Description | Defined By |
---|---|---|---|
$bcc | string|array | The Bcc (hidden copy receiver) addresses of this message. | yii\swiftmailer\Message |
$cc | string|array | The Cc (additional copy receiver) addresses of this message. | yii\swiftmailer\Message |
$charset | string | The character set of this message. | yii\swiftmailer\Message |
$from | string|array | The sender | yii\swiftmailer\Message |
$headers | array | Headers in format: [name => value] . |
yii\swiftmailer\Message |
$htmlBody | string | Message HTML content. | yii\swiftmailer\Message |
$mailer | yii\mail\MailerInterface|null | The mailer instance that created this message. | yii\mail\BaseMessage |
$priority | integer | Priority value as integer in range: 1..5 , where 1 is the highest priority and 5 is the lowest. |
yii\swiftmailer\Message |
$readReceiptTo | string | Receipt receive email addresses. | yii\swiftmailer\Message |
$replyTo | string|array | The reply-to address of this message. | yii\swiftmailer\Message |
$returnPath | string | The bounce email address. | yii\swiftmailer\Message |
$signature | array|callable|\Swift_Signer | Signature specification. | yii\swiftmailer\Message |
$subject | string | The message subject | yii\swiftmailer\Message |
$swiftMessage | \Swift_Message | Swift message instance. | yii\swiftmailer\Message |
$textBody | string | Message plain text content. | yii\swiftmailer\Message |
$to | string|array | The message recipients | yii\swiftmailer\Message |
Public Methods
Method | Description | Defined By |
---|---|---|
__call() | Calls the named method which is not a class method. | yii\base\BaseObject |
__clone() | This method is called after the object is created by cloning an existing one. | yii\swiftmailer\Message |
__construct() | Constructor. | yii\base\BaseObject |
__get() | Returns the value of an object property. | yii\base\BaseObject |
__isset() | Checks if a property is set, i.e. defined and not null. | yii\base\BaseObject |
__set() | Sets value of an object property. | yii\base\BaseObject |
__toString() | PHP magic method that returns the string representation of this object. | yii\mail\BaseMessage |
__unset() | Sets an object property to null. | yii\base\BaseObject |
addHeader() | Adds custom header value to the message. | yii\swiftmailer\Message |
addSignature() | Adds message signature. | yii\swiftmailer\Message |
attach() | Attaches existing file to the email message. | yii\swiftmailer\Message |
attachContent() | Attach specified content as file for the email message. | yii\swiftmailer\Message |
canGetProperty() | Returns a value indicating whether a property can be read. | yii\base\BaseObject |
canSetProperty() | Returns a value indicating whether a property can be set. | yii\base\BaseObject |
className() | Returns the fully qualified name of this class. | yii\base\BaseObject |
embed() | Attach a file and return it's CID source. | yii\swiftmailer\Message |
embedContent() | Attach a content as file and return it's CID source. | yii\swiftmailer\Message |
getBcc() | Returns the Bcc (hidden copy receiver) addresses of this message. | yii\swiftmailer\Message |
getCc() | Returns the Cc (additional copy receiver) addresses of this message. | yii\swiftmailer\Message |
getCharset() | Returns the character set of this message. | yii\swiftmailer\Message |
getFrom() | Returns the message sender. | yii\swiftmailer\Message |
getHeader() | Returns all values for the specified header. | yii\swiftmailer\Message |
getMailer() | returns mailer instance. | yii\swiftmailer\Message |
getPriority() | Returns the priority of this message. | yii\swiftmailer\Message |
getReadReceiptTo() | Get the addresses to which a read-receipt will be sent. | yii\swiftmailer\Message |
getReplyTo() | Returns the reply-to address of this message. | yii\swiftmailer\Message |
getReturnPath() | Returns the return-path (the bounce address) of this message. | yii\swiftmailer\Message |
getSubject() | Returns the message subject. | yii\swiftmailer\Message |
getSwiftMessage() | yii\swiftmailer\Message | |
getTo() | Returns the message recipient(s). | yii\swiftmailer\Message |
hasMethod() | Returns a value indicating whether a method is defined. | yii\base\BaseObject |
hasProperty() | Returns a value indicating whether a property is defined. | yii\base\BaseObject |
init() | Initializes the object. | yii\base\BaseObject |
send() | Sends this email message. | yii\mail\BaseMessage |
setBcc() | Sets the Bcc (hidden copy receiver) addresses of this message. | yii\swiftmailer\Message |
setCc() | Sets the Cc (additional copy receiver) addresses of this message. | yii\swiftmailer\Message |
setCharset() | Sets the character set of this message. | yii\swiftmailer\Message |
setFrom() | Sets the message sender. | yii\swiftmailer\Message |
setHeader() | Sets custom header value to the message. | yii\swiftmailer\Message |
setHeaders() | Sets custom header values to the message. | yii\swiftmailer\Message |
setHtmlBody() | Sets message HTML content. | yii\swiftmailer\Message |
setPriority() | Set the priority of this message. | yii\swiftmailer\Message |
setReadReceiptTo() | Sets the ask for a delivery receipt from the recipient to be sent to $addresses. | yii\swiftmailer\Message |
setReplyTo() | Sets the reply-to address of this message. | yii\swiftmailer\Message |
setReturnPath() | Set the return-path (the bounce address) of this message. | yii\swiftmailer\Message |
setSignature() | Sets message signature | yii\swiftmailer\Message |
setSubject() | Sets the message subject. | yii\swiftmailer\Message |
setTextBody() | Sets message plain text content. | yii\swiftmailer\Message |
setTo() | Sets the message recipient(s). | yii\swiftmailer\Message |
toString() | Returns string representation of this message. | yii\swiftmailer\Message |
Protected Methods
Method | Description | Defined By |
---|---|---|
createSwiftMessage() | Creates the Swift email message instance. | yii\swiftmailer\Message |
createSwiftSigner() | Creates signer from it's configuration. | yii\swiftmailer\Message |
setBody() | Sets the message body. | yii\swiftmailer\Message |
Property Details
The Bcc (hidden copy receiver) addresses of this message.
The Cc (additional copy receiver) addresses of this message.
The character set of this message.
Priority value as integer in range: 1..5
, where 1 is the highest priority and 5
is the lowest.
Receipt receive email addresses. Note that the type of this property differs in getter and setter. See getReadReceiptTo() and setReadReceiptTo() for details.
The reply-to address of this message.
Signature specification. See addSignature() for details on how it should be specified.
The message subject
Method Details
Defined in: yii\base\BaseObject::__call()
Calls the named method which is not a class method.
Do not call this method directly as it is a PHP magic method that will be implicitly called when an unknown method is being invoked.
public mixed __call ( $name, $params ) | ||
$name | string |
The method name |
$params | array |
Method parameters |
return | mixed |
The method return value |
---|---|---|
throws | yii\base\UnknownMethodException |
when calling unknown method |
public function __call($name, $params)
{
throw new UnknownMethodException('Calling unknown method: ' . get_class($this) . "::$name()");
}
This method is called after the object is created by cloning an existing one.
It ensures $swiftMessage and signers is also cloned.
public void __clone ( ) |
public function __clone()
{
if ($this->_swiftMessage !== null) {
$this->_swiftMessage = clone $this->_swiftMessage;
}
foreach ($this->signers as $key => $signer) {
$this->signers[$key] = clone $signer;
}
}
Defined in: yii\base\BaseObject::__construct()
Constructor.
The default implementation does two things:
- Initializes the object with the given configuration
$config
. - Call init().
If this method is overridden in a child class, it is recommended that
- the last parameter of the constructor is a configuration array, like
$config
here. - call the parent implementation at the end of the constructor.
public void __construct ( $config = [] ) | ||
$config | array |
Name-value pairs that will be used to initialize the object properties |
public function __construct($config = [])
{
if (!empty($config)) {
Yii::configure($this, $config);
}
$this->init();
}
Defined in: yii\base\BaseObject::__get()
Returns the value of an object property.
Do not call this method directly as it is a PHP magic method that
will be implicitly called when executing $value = $object->property;
.
See also __set().
public mixed __get ( $name ) | ||
$name | string |
The property name |
return | mixed |
The property value |
---|---|---|
throws | yii\base\UnknownPropertyException |
if the property is not defined |
throws | yii\base\InvalidCallException |
if the property is write-only |
public function __get($name)
{
$getter = 'get' . $name;
if (method_exists($this, $getter)) {
return $this->$getter();
} elseif (method_exists($this, 'set' . $name)) {
throw new InvalidCallException('Getting write-only property: ' . get_class($this) . '::' . $name);
}
throw new UnknownPropertyException('Getting unknown property: ' . get_class($this) . '::' . $name);
}
Defined in: yii\base\BaseObject::__isset()
Checks if a property is set, i.e. defined and not null.
Do not call this method directly as it is a PHP magic method that
will be implicitly called when executing isset($object->property)
.
Note that if the property is not defined, false will be returned.
public boolean __isset ( $name ) | ||
$name | string |
The property name or the event name |
return | boolean |
Whether the named property is set (not null). |
---|
public function __isset($name)
{
$getter = 'get' . $name;
if (method_exists($this, $getter)) {
return $this->$getter() !== null;
}
return false;
}
Defined in: yii\base\BaseObject::__set()
Sets value of an object property.
Do not call this method directly as it is a PHP magic method that
will be implicitly called when executing $object->property = $value;
.
See also __get().
public void __set ( $name, $value ) | ||
$name | string |
The property name or the event name |
$value | mixed |
The property value |
throws | yii\base\UnknownPropertyException |
if the property is not defined |
---|---|---|
throws | yii\base\InvalidCallException |
if the property is read-only |
public function __set($name, $value)
{
$setter = 'set' . $name;
if (method_exists($this, $setter)) {
$this->$setter($value);
} elseif (method_exists($this, 'get' . $name)) {
throw new InvalidCallException('Setting read-only property: ' . get_class($this) . '::' . $name);
} else {
throw new UnknownPropertyException('Setting unknown property: ' . get_class($this) . '::' . $name);
}
}
Defined in: yii\mail\BaseMessage::__toString()
PHP magic method that returns the string representation of this object.
public string __toString ( ) | ||
return | string |
The string representation of this object. |
---|
public function __toString()
{
// __toString cannot throw exception
// use trigger_error to bypass this limitation
try {
return $this->toString();
} catch (\Exception $e) {
ErrorHandler::convertExceptionToError($e);
return '';
}
}
Defined in: yii\base\BaseObject::__unset()
Sets an object property to null.
Do not call this method directly as it is a PHP magic method that
will be implicitly called when executing unset($object->property)
.
Note that if the property is not defined, this method will do nothing. If the property is read-only, it will throw an exception.
public void __unset ( $name ) | ||
$name | string |
The property name |
throws | yii\base\InvalidCallException |
if the property is read only. |
---|
public function __unset($name)
{
$setter = 'set' . $name;
if (method_exists($this, $setter)) {
$this->$setter(null);
} elseif (method_exists($this, 'get' . $name)) {
throw new InvalidCallException('Unsetting read-only property: ' . get_class($this) . '::' . $name);
}
}
Adds custom header value to the message.
Several invocations of this method with the same name will add multiple header values.
public $this addHeader ( $name, $value ) | ||
$name | string |
Header name. |
$value | string |
Header value. |
return | $this |
Self reference. |
---|
public function addHeader($name, $value)
{
$this->getSwiftMessage()->getHeaders()->addTextHeader($name, $value);
return $this;
}
Adds message signature.
public $this addSignature ( $signature ) | ||
$signature | array|callable|\Swift_Signer |
Signature specification, this can be:
|
return | $this |
Self reference |
---|---|---|
throws | yii\base\InvalidConfigException |
on invalid signature configuration |
public function addSignature($signature)
{
if ($signature instanceof \Swift_Signer) {
$signer = $signature;
} elseif (is_callable($signature)) {
$signer = call_user_func($signature);
} elseif (is_array($signature)) {
$signer = $this->createSwiftSigner($signature);
} else {
throw new InvalidConfigException('Signature should be instance of "Swift_Signer", callable or array configuration');
}
$this->getSwiftMessage()->attachSigner($signer);
$this->signers[] = $signer;
return $this;
}
Attaches existing file to the email message.
public $this attach ( $fileName, array $options = [] ) | ||
$fileName | string |
Full file name |
$options | array |
Options for embed file. Valid options are:
|
return | $this |
Self reference. |
---|
public function attach($fileName, array $options = [])
{
$attachment = \Swift_Attachment::fromPath($fileName);
if (!empty($options['fileName'])) {
$attachment->setFilename($options['fileName']);
}
if (!empty($options['contentType'])) {
$attachment->setContentType($options['contentType']);
}
$this->getSwiftMessage()->attach($attachment);
return $this;
}
Attach specified content as file for the email message.
public $this attachContent ( $content, array $options = [] ) | ||
$content | string |
Attachment file content. |
$options | array |
Options for embed file. Valid options are:
|
return | $this |
Self reference. |
---|
public function attachContent($content, array $options = [])
{
$attachment = new \Swift_Attachment($content);
if (!empty($options['fileName'])) {
$attachment->setFilename($options['fileName']);
}
if (!empty($options['contentType'])) {
$attachment->setContentType($options['contentType']);
}
if (!empty($options['setDisposition'])) {
$attachment->setDisposition($options['setDisposition']);
}
$this->getSwiftMessage()->attach($attachment);
return $this;
}
Defined in: yii\base\BaseObject::canGetProperty()
Returns a value indicating whether a property can be read.
A property is readable if:
- the class has a getter method associated with the specified name (in this case, property name is case-insensitive);
- the class has a member variable with the specified name (when
$checkVars
is true);
See also canSetProperty().
public boolean canGetProperty ( $name, $checkVars = true ) | ||
$name | string |
The property name |
$checkVars | boolean |
Whether to treat member variables as properties |
return | boolean |
Whether the property can be read |
---|
public function canGetProperty($name, $checkVars = true)
{
return method_exists($this, 'get' . $name) || $checkVars && property_exists($this, $name);
}
Defined in: yii\base\BaseObject::canSetProperty()
Returns a value indicating whether a property can be set.
A property is writable if:
- the class has a setter method associated with the specified name (in this case, property name is case-insensitive);
- the class has a member variable with the specified name (when
$checkVars
is true);
See also canGetProperty().
public boolean canSetProperty ( $name, $checkVars = true ) | ||
$name | string |
The property name |
$checkVars | boolean |
Whether to treat member variables as properties |
return | boolean |
Whether the property can be written |
---|
public function canSetProperty($name, $checkVars = true)
{
return method_exists($this, 'set' . $name) || $checkVars && property_exists($this, $name);
}
::class
instead.
Defined in: yii\base\BaseObject::className()
Returns the fully qualified name of this class.
public static string className ( ) | ||
return | string |
The fully qualified name of this class. |
---|
public static function className()
{
return get_called_class();
}
Creates the Swift email message instance.
protected \Swift_Message createSwiftMessage ( ) | ||
return | \Swift_Message |
Email message instance. |
---|
protected function createSwiftMessage()
{
return new \Swift_Message();
}
Creates signer from it's configuration.
protected \Swift_Signer createSwiftSigner ( $signature ) | ||
$signature | array |
Signature configuration:
|
return | \Swift_Signer |
Signer instance |
---|---|---|
throws | yii\base\InvalidConfigException |
on invalid configuration provided |
protected function createSwiftSigner($signature)
{
if (!isset($signature['type'])) {
throw new InvalidConfigException('Signature configuration should contain "type" key');
}
$signature['type'] = strtolower($signature['type']);
if (!in_array($signature['type'], ['dkim', 'opendkim'], true)) {
throw new InvalidConfigException("Unrecognized signature type '{$signature['type']}'");
}
if (isset($signature['key'])) {
$privateKey = $signature['key'];
} elseif (isset($signature['file'])) {
$privateKey = file_get_contents(Yii::getAlias($signature['file']));
} else {
throw new InvalidConfigException("Either 'key' or 'file' signature option should be specified");
}
$domain = ArrayHelper::getValue($signature, 'domain');
$selector = ArrayHelper::getValue($signature, 'selector');
if ($signature['type'] === 'opendkim') {
Yii::warning(__METHOD__ . '(): signature type "opendkim" is deprecated, use "dkim" instead.');
return new \Swift_Signers_OpenDKIMSigner($privateKey, $domain, $selector);
}
return new \Swift_Signers_DKIMSigner($privateKey, $domain, $selector);
}
Attach a file and return it's CID source.
This method should be used when embedding images or other data in a message.
public string embed ( $fileName, array $options = [] ) | ||
$fileName | string |
File name. |
$options | array |
Options for embed file. Valid options are:
|
return | string |
Attachment CID. |
---|
public function embed($fileName, array $options = [])
{
$embedFile = \Swift_EmbeddedFile::fromPath($fileName);
if (!empty($options['fileName'])) {
$embedFile->setFilename($options['fileName']);
}
if (!empty($options['contentType'])) {
$embedFile->setContentType($options['contentType']);
}
return $this->getSwiftMessage()->embed($embedFile);
}
Attach a content as file and return it's CID source.
This method should be used when embedding images or other data in a message.
public string embedContent ( $content, array $options = [] ) | ||
$content | string |
Attachment file content. |
$options | array |
Options for embed file. Valid options are:
|
return | string |
Attachment CID. |
---|
public function embedContent($content, array $options = [])
{
$embedFile = new \Swift_EmbeddedFile($content);
if (!empty($options['fileName'])) {
$embedFile->setFilename($options['fileName']);
}
if (!empty($options['contentType'])) {
$embedFile->setContentType($options['contentType']);
}
return $this->getSwiftMessage()->embed($embedFile);
}
Returns the Bcc (hidden copy receiver) addresses of this message.
public string|array getBcc ( ) | ||
return | string|array |
The Bcc (hidden copy receiver) addresses of this message. |
---|
public function getBcc()
{
return $this->getSwiftMessage()->getBcc();
}
Returns the Cc (additional copy receiver) addresses of this message.
public string|array getCc ( ) | ||
return | string|array |
The Cc (additional copy receiver) addresses of this message. |
---|
public function getCc()
{
return $this->getSwiftMessage()->getCc();
}
Returns the character set of this message.
public string getCharset ( ) | ||
return | string |
The character set of this message. |
---|
public function getCharset()
{
return $this->getSwiftMessage()->getCharset();
}
Returns the message sender.
public string|array getFrom ( ) | ||
return | string|array |
The sender |
---|
public function getFrom()
{
return $this->getSwiftMessage()->getFrom();
}
Returns all values for the specified header.
public array getHeader ( $name ) | ||
$name | string |
Header name. |
return | array |
Header values list. |
---|
public function getHeader($name)
{
$headerSet = $this->getSwiftMessage()->getHeaders();
if (!$headerSet->has($name)) {
return [];
}
$headers = [];
foreach ($headerSet->getAll($name) as $header) {
$headers[] = $header->getValue();
}
return $headers;
}
returns mailer instance.
public yii\swiftmailer\Mailer getMailer ( ) | ||
return | yii\swiftmailer\Mailer |
---|
Returns the priority of this message.
public integer getPriority ( ) | ||
return | integer |
Priority value as integer in range: |
---|
public function getPriority()
{
return $this->getSwiftMessage()->getPriority();
}
Get the addresses to which a read-receipt will be sent.
public string getReadReceiptTo ( ) | ||
return | string |
Receipt receive email addresses. |
---|
public function getReadReceiptTo()
{
return $this->getSwiftMessage()->getReadReceiptTo();
}
Returns the reply-to address of this message.
public string|array getReplyTo ( ) | ||
return | string|array |
The reply-to address of this message. |
---|
public function getReplyTo()
{
return $this->getSwiftMessage()->getReplyTo();
}
Returns the return-path (the bounce address) of this message.
public string getReturnPath ( ) | ||
return | string |
The bounce email address. |
---|
public function getReturnPath()
{
return $this->getSwiftMessage()->getReturnPath();
}
Returns the message subject.
public string getSubject ( ) | ||
return | string |
The message subject |
---|
public function getSubject()
{
return $this->getSwiftMessage()->getSubject();
}
public \Swift_Message getSwiftMessage ( ) | ||
return | \Swift_Message |
Swift message instance. |
---|
public function getSwiftMessage()
{
if ($this->_swiftMessage === null) {
$this->_swiftMessage = $this->createSwiftMessage();
}
return $this->_swiftMessage;
}
Returns the message recipient(s).
public string|array getTo ( ) | ||
return | string|array |
The message recipients |
---|
public function getTo()
{
return $this->getSwiftMessage()->getTo();
}
Defined in: yii\base\BaseObject::hasMethod()
Returns a value indicating whether a method is defined.
The default implementation is a call to php function method_exists()
.
You may override this method when you implemented the php magic method __call()
.
public boolean hasMethod ( $name ) | ||
$name | string |
The method name |
return | boolean |
Whether the method is defined |
---|
public function hasMethod($name)
{
return method_exists($this, $name);
}
Defined in: yii\base\BaseObject::hasProperty()
Returns a value indicating whether a property is defined.
A property is defined if:
- the class has a getter or setter method associated with the specified name (in this case, property name is case-insensitive);
- the class has a member variable with the specified name (when
$checkVars
is true);
See also:
public boolean hasProperty ( $name, $checkVars = true ) | ||
$name | string |
The property name |
$checkVars | boolean |
Whether to treat member variables as properties |
return | boolean |
Whether the property is defined |
---|
public function hasProperty($name, $checkVars = true)
{
return $this->canGetProperty($name, $checkVars) || $this->canSetProperty($name, false);
}
Defined in: yii\base\BaseObject::init()
Initializes the object.
This method is invoked at the end of the constructor after the object is initialized with the given configuration.
public void init ( ) |
public function init()
{
}
Defined in: yii\mail\BaseMessage::send()
Sends this email message.
public boolean send ( yii\mail\MailerInterface $mailer = null ) | ||
$mailer | yii\mail\MailerInterface|null |
The mailer that should be used to send this message. If no mailer is given it will first check if $mailer is set and if not, the "mailer" application component will be used instead. |
return | boolean |
Whether this message is sent successfully. |
---|
public function send(MailerInterface $mailer = null)
{
if ($mailer === null && $this->mailer === null) {
$mailer = Yii::$app->getMailer();
} elseif ($mailer === null) {
$mailer = $this->mailer;
}
return $mailer->send($this);
}
Sets the Bcc (hidden copy receiver) addresses of this message.
public $this setBcc ( $bcc ) | ||
$bcc | string|array |
Hidden copy receiver email address.
You may pass an array of addresses if multiple recipients should receive this message.
You may also specify receiver name in addition to email address using format:
|
return | $this |
Self reference. |
---|
public function setBcc($bcc)
{
$this->getSwiftMessage()->setBcc($bcc);
return $this;
}
Sets the message body.
If body is already set and its content type matches given one, it will be overridden, if content type miss match the multipart message will be composed.
protected void setBody ( $body, $contentType ) | ||
$body | string |
Body content. |
$contentType | string |
Body content type. |
protected function setBody($body, $contentType)
{
$message = $this->getSwiftMessage();
$oldBody = $message->getBody();
$charset = $message->getCharset();
if (empty($oldBody)) {
$parts = $message->getChildren();
$partFound = false;
foreach ($parts as $key => $part) {
if (!($part instanceof \Swift_Mime_Attachment)) {
/* @var $part \Swift_Mime_MimePart */
if ($part->getContentType() == $contentType) {
$charset = $part->getCharset();
unset($parts[$key]);
$partFound = true;
break;
}
}
}
if ($partFound) {
reset($parts);
$message->setChildren($parts);
$message->addPart($body, $contentType, $charset);
} else {
$message->setBody($body, $contentType);
}
} else {
$oldContentType = $message->getContentType();
if ($oldContentType == $contentType) {
$message->setBody($body, $contentType);
} else {
$message->setBody(null);
$message->setContentType(null);
$message->addPart($oldBody, $oldContentType, $charset);
$message->addPart($body, $contentType, $charset);
}
}
}
Sets the Cc (additional copy receiver) addresses of this message.
public $this setCc ( $cc ) | ||
$cc | string|array |
Copy receiver email address.
You may pass an array of addresses if multiple recipients should receive this message.
You may also specify receiver name in addition to email address using format:
|
return | $this |
Self reference. |
---|
public function setCc($cc)
{
$this->getSwiftMessage()->setCc($cc);
return $this;
}
Sets the character set of this message.
public $this setCharset ( $charset ) | ||
$charset | string |
Character set name. |
return | $this |
Self reference. |
---|
public function setCharset($charset)
{
$this->getSwiftMessage()->setCharset($charset);
return $this;
}
Sets the message sender.
public $this setFrom ( $from ) | ||
$from | string|array |
Sender email address.
You may pass an array of addresses if this message is from multiple people.
You may also specify sender name in addition to email address using format:
|
return | $this |
Self reference. |
---|
public function setFrom($from)
{
$this->getSwiftMessage()->setFrom($from);
return $this;
}
Sets custom header value to the message.
public $this setHeader ( $name, $value ) | ||
$name | string |
Header name. |
$value | string|array |
Header value or values. |
return | $this |
Self reference. |
---|
public function setHeader($name, $value)
{
$headerSet = $this->getSwiftMessage()->getHeaders();
if ($headerSet->has($name)) {
$headerSet->remove($name);
}
foreach ((array)$value as $v) {
$headerSet->addTextHeader($name, $v);
}
return $this;
}
Sets custom header values to the message.
public $this setHeaders ( $headers ) | ||
$headers | array |
Headers in format: |
return | $this |
Self reference. |
---|
public function setHeaders($headers)
{
foreach ($headers as $name => $value) {
$this->setHeader($name, $value);
}
return $this;
}
Sets message HTML content.
public $this setHtmlBody ( $html ) | ||
$html | string |
Message HTML content. |
return | $this |
Self reference. |
---|
public function setHtmlBody($html)
{
$this->setBody($html, 'text/html');
return $this;
}
Set the priority of this message.
public $this setPriority ( $priority ) | ||
$priority | integer |
Priority value, should be an integer in range: |
return | $this |
Self reference. |
---|
public function setPriority($priority)
{
$this->getSwiftMessage()->setPriority($priority);
return $this;
}
Sets the ask for a delivery receipt from the recipient to be sent to $addresses.
public $this setReadReceiptTo ( $addresses ) | ||
$addresses | string|array |
Receipt receive email address(es). |
return | $this |
Self reference. |
---|
public function setReadReceiptTo($addresses)
{
$this->getSwiftMessage()->setReadReceiptTo($addresses);
return $this;
}
Sets the reply-to address of this message.
public $this setReplyTo ( $replyTo ) | ||
$replyTo | string|array |
The reply-to address.
You may pass an array of addresses if this message should be replied to multiple people.
You may also specify reply-to name in addition to email address using format:
|
return | $this |
Self reference. |
---|
public function setReplyTo($replyTo)
{
$this->getSwiftMessage()->setReplyTo($replyTo);
return $this;
}
Set the return-path (the bounce address) of this message.
public $this setReturnPath ( $address ) | ||
$address | string |
The bounce email address. |
return | $this |
Self reference. |
---|
public function setReturnPath($address)
{
$this->getSwiftMessage()->setReturnPath($address);
return $this;
}
Sets message signature
public $this setSignature ( $signature ) | ||
$signature | array|callable|\Swift_Signer |
Signature specification. See addSignature() for details on how it should be specified. |
return | $this |
Self reference. |
---|
public function setSignature($signature)
{
if (!empty($this->signers)) {
// clear previously set signers
$swiftMessage = $this->getSwiftMessage();
foreach ($this->signers as $signer) {
$swiftMessage->detachSigner($signer);
}
$this->signers = [];
}
return $this->addSignature($signature);
}
Sets the message subject.
public $this setSubject ( $subject ) | ||
$subject | string |
Message subject |
return | $this |
Self reference. |
---|
public function setSubject($subject)
{
$this->getSwiftMessage()->setSubject($subject);
return $this;
}
Sets message plain text content.
public $this setTextBody ( $text ) | ||
$text | string |
Message plain text content. |
return | $this |
Self reference. |
---|
public function setTextBody($text)
{
$this->setBody($text, 'text/plain');
return $this;
}
Sets the message recipient(s).
public $this setTo ( $to ) | ||
$to | string|array |
Receiver email address.
You may pass an array of addresses if multiple recipients should receive this message.
You may also specify receiver name in addition to email address using format:
|
return | $this |
Self reference. |
---|
public function setTo($to)
{
$this->getSwiftMessage()->setTo($to);
return $this;
}