Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Static Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes | Static Protected Attributes
Zend_Mail Class Reference
Inheritance diagram for Zend_Mail:
Zend_Mime_Message

Public Member Functions

 __construct ($charset=null)
 
 getCharset ()
 
 setType ($type)
 
 getType ()
 
 setMimeBoundary ($boundary)
 
 getMimeBoundary ()
 
 getEncodingOfHeaders ()
 
 getHeaderEncoding ()
 
 setEncodingOfHeaders ($encoding)
 
 setHeaderEncoding ($encoding)
 
 setBodyText ($txt, $charset=null, $encoding=Zend_Mime::ENCODING_QUOTEDPRINTABLE)
 
 getBodyText ($textOnly=false)
 
 setBodyHtml ($html, $charset=null, $encoding=Zend_Mime::ENCODING_QUOTEDPRINTABLE)
 
 getBodyHtml ($htmlOnly=false)
 
 addAttachment (Zend_Mime_Part $attachment)
 
 createAttachment ($body, $mimeType=Zend_Mime::TYPE_OCTETSTREAM, $disposition=Zend_Mime::DISPOSITION_ATTACHMENT, $encoding=Zend_Mime::ENCODING_BASE64, $filename=null)
 
 getPartCount ()
 
 addTo ($email, $name='')
 
 addCc ($email, $name='')
 
 addBcc ($email)
 
 getRecipients ()
 
 clearHeader ($headerName)
 
 clearRecipients ()
 
 setFrom ($email, $name=null)
 
 setReplyTo ($email, $name=null)
 
 getFrom ()
 
 getReplyTo ()
 
 clearFrom ()
 
 clearReplyTo ()
 
 setFromToDefaultFrom ()
 
 setReplyToFromDefault ()
 
 setReturnPath ($email)
 
 getReturnPath ()
 
 clearReturnPath ()
 
 setSubject ($subject)
 
 getSubject ()
 
 clearSubject ()
 
 setDate ($date=null)
 
 getDate ()
 
 clearDate ()
 
 setMessageId ($id=true)
 
 getMessageId ()
 
 clearMessageId ()
 
 createMessageId ()
 
 addHeader ($name, $value, $append=false)
 
 getHeaders ()
 
 send ($transport=null)
 
- Public Member Functions inherited from Zend_Mime_Message
 getParts ()
 
 setParts ($parts)
 
 addPart (Zend_Mime_Part $part)
 
 isMultiPart ()
 
 setMime (Zend_Mime $mime)
 
 getMime ()
 
 generateMessage ($EOL=Zend_Mime::LINEEND)
 
 getPartHeadersArray ($partnum)
 
 getPartHeaders ($partnum, $EOL=Zend_Mime::LINEEND)
 
 getPartContent ($partnum, $EOL=Zend_Mime::LINEEND)
 

Static Public Member Functions

static setDefaultTransport (Zend_Mail_Transport_Abstract $transport)
 
static getDefaultTransport ()
 
static clearDefaultTransport ()
 
static setDefaultFrom ($email, $name=null)
 
static getDefaultFrom ()
 
static clearDefaultFrom ()
 
static setDefaultReplyTo ($email, $name=null)
 
static getDefaultReplyTo ()
 
static clearDefaultReplyTo ()
 
- Static Public Member Functions inherited from Zend_Mime_Message
static createFromMessage ( $message, $boundary, $EOL=Zend_Mime::LINEEND)
 

Data Fields

 $hasAttachments = false
 

Protected Member Functions

 _encodeHeader ($value)
 
 _storeHeader ($headerName, $value, $append=false)
 
 _clearHeader ($headerName)
 
 _addRecipientAndHeader ($headerName, $email, $name)
 
 _filterEmail ($email)
 
 _filterName ($name)
 
 _filterOther ($data)
 
 _formatAddress ($email, $name)
 

Protected Attributes

 $_charset = 'iso-8859-1'
 
 $_headers = array()
 
 $_headerEncoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE
 
 $_from = null
 
 $_to = array()
 
 $_recipients = array()
 
 $_replyTo = null
 
 $_returnPath = null
 
 $_subject = null
 
 $_date = null
 
 $_messageId = null
 
 $_bodyText = false
 
 $_bodyHtml = false
 
 $_mimeBoundary = null
 
 $_type = null
 
- Protected Attributes inherited from Zend_Mime_Message
 $_parts = array()
 
 $_mime = null
 

Static Protected Attributes

static $_defaultTransport = null
 
static $_defaultFrom
 
static $_defaultReplyTo
 

Additional Inherited Members

- Static Protected Member Functions inherited from Zend_Mime_Message
static _disassembleMime ($body, $boundary)
 

Detailed Description

Definition at line 52 of file Mail.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $charset = null)

Public constructor

Parameters
string$charset

Definition at line 213 of file Mail.php.

214  {
215  if ($charset != null) {
216  $this->_charset = $charset;
217  }
218  }

Member Function Documentation

◆ _addRecipientAndHeader()

_addRecipientAndHeader (   $headerName,
  $email,
  $name 
)
protected

Helper function for adding a recipient and the corresponding header

Parameters
string$headerName
string$email
string$name

Definition at line 557 of file Mail.php.

558  {
559  $email = $this->_filterEmail($email);
560  $name = $this->_filterName($name);
561  // prevent duplicates
562  $this->_recipients[$email] = 1;
563  $this->_storeHeader($headerName, $this->_formatAddress($email, $name), true);
564  }
$email
Definition: details.phtml:13
_storeHeader($headerName, $value, $append=false)
Definition: Mail.php:525
_filterName($name)
Definition: Mail.php:1232
_filterEmail($email)
Definition: Mail.php:1212
_formatAddress($email, $name)
Definition: Mail.php:1268
if(!isset($_GET['name'])) $name
Definition: log.php:14

◆ _clearHeader()

_clearHeader (   $headerName)
protected

Clear header from the message

Parameters
string$headerName
Deprecated:
use public method directly

Definition at line 545 of file Mail.php.

546  {
547  $this->clearHeader($headerName);
548  }
clearHeader($headerName)
Definition: Mail.php:644

◆ _encodeHeader()

_encodeHeader (   $value)
protected

Encode header fields

Encodes header content according to RFC1522 if it contains non-printable characters.

Parameters
string$value
Returns
string

Definition at line 502 of file Mail.php.

503  {
504  if (Zend_Mime::isPrintable($value) === false) {
507  } else {
509  }
510  }
511 
512  return $value;
513  }
getCharset()
Definition: Mail.php:225
const ENCODING_QUOTEDPRINTABLE
Definition: Mime.php:37
static encodeQuotedPrintableHeader( $str, $charset, $lineLength=self::LINELENGTH, $lineEnd=self::LINEEND)
Definition: Mime.php:488
const LINEEND
Definition: Mime.php:42
const LINELENGTH
Definition: Mime.php:41
$value
Definition: gender.phtml:16
static isPrintable($str)
Definition: Mime.php:410
static encodeBase64Header( $str, $charset, $lineLength=self::LINELENGTH, $lineEnd=self::LINEEND)
Definition: Mime.php:565
getHeaderEncoding()
Definition: Mail.php:311

◆ _filterEmail()

_filterEmail (   $email)
protected

Filter of email data

Parameters
string$email
Returns
string

Definition at line 1212 of file Mail.php.

1213  {
1214  $rule = array("\r" => '',
1215  "\n" => '',
1216  "\t" => '',
1217  '"' => '',
1218  ',' => '',
1219  '<' => '',
1220  '>' => '',
1221  );
1222 
1223  return strtr($email, $rule);
1224  }
$email
Definition: details.phtml:13

◆ _filterName()

_filterName (   $name)
protected

Filter of name data

Parameters
string$name
Returns
string

Definition at line 1232 of file Mail.php.

1233  {
1234  $rule = array("\r" => '',
1235  "\n" => '',
1236  "\t" => '',
1237  '"' => "'",
1238  '<' => '[',
1239  '>' => ']',
1240  );
1241 
1242  return trim(strtr($name, $rule));
1243  }
if(!isset($_GET['name'])) $name
Definition: log.php:14

◆ _filterOther()

_filterOther (   $data)
protected

Filter of other data

Parameters
string$data
Returns
string

Definition at line 1251 of file Mail.php.

1252  {
1253  $rule = array("\r" => '',
1254  "\n" => '',
1255  "\t" => '',
1256  );
1257 
1258  return strtr($data, $rule);
1259  }

◆ _formatAddress()

_formatAddress (   $email,
  $name 
)
protected

Formats e-mail address

Parameters
string$email
string$name
Returns
string

Definition at line 1268 of file Mail.php.

1269  {
1270  if ($name === '' || $name === null || $name === $email) {
1271  return $email;
1272  } else {
1273  $encodedName = $this->_encodeHeader($name);
1274  if ($encodedName === $name && strcspn($name, '()<>[]:;@\\,.') != strlen($name)) {
1275  $format = '"%s" <%s>';
1276  } else {
1277  $format = '%s <%s>';
1278  }
1279  return sprintf($format, $encodedName, $email);
1280  }
1281  }
$email
Definition: details.phtml:13
_encodeHeader($value)
Definition: Mail.php:502
$format
Definition: list.phtml:12
if(!isset($_GET['name'])) $name
Definition: log.php:14

◆ _storeHeader()

_storeHeader (   $headerName,
  $value,
  $append = false 
)
protected

Add a header to the message

Adds a header to this message. If append is true and the header already exists, raises a flag indicating that the header should be appended.

Parameters
string$headerName
string$value
bool$append

Definition at line 525 of file Mail.php.

526  {
527  if (isset($this->_headers[$headerName])) {
528  $this->_headers[$headerName][] = $value;
529  } else {
530  $this->_headers[$headerName] = array($value);
531  }
532 
533  if ($append) {
534  $this->_headers[$headerName]['append'] = true;
535  }
536 
537  }
$value
Definition: gender.phtml:16

◆ addAttachment()

addAttachment ( Zend_Mime_Part  $attachment)

Adds an existing attachment to the mail message

Parameters
Zend_Mime_Part$attachment
Returns
Zend_Mail Provides fluent interface

Definition at line 443 of file Mail.php.

444  {
445  $this->addPart($attachment);
446  $this->hasAttachments = true;
447 
448  return $this;
449  }
addPart(Zend_Mime_Part $part)
Definition: Message.php:79

◆ addBcc()

addBcc (   $email)

Adds Bcc recipient, $email can be an array, or a single string address

Parameters
string | array$email
Returns
Zend_Mail Provides fluent interface

Definition at line 615 of file Mail.php.

616  {
617  if (!is_array($email)) {
618  $email = array($email);
619  }
620 
621  foreach ($email as $recipient) {
622  $this->_addRecipientAndHeader('Bcc', $recipient, '');
623  }
624 
625  return $this;
626  }
$email
Definition: details.phtml:13
_addRecipientAndHeader($headerName, $email, $name)
Definition: Mail.php:557

◆ addCc()

addCc (   $email,
  $name = '' 
)

Adds Cc-header and recipient, $email can be an array, or a single string address

Parameters
string | array$email
string$name
Returns
Zend_Mail Provides fluent interface

Definition at line 596 of file Mail.php.

597  {
598  if (!is_array($email)) {
599  $email = array($name => $email);
600  }
601 
602  foreach ($email as $n => $recipient) {
603  $this->_addRecipientAndHeader('Cc', $recipient, is_int($n) ? '' : $n);
604  }
605 
606  return $this;
607  }
$email
Definition: details.phtml:13
_addRecipientAndHeader($headerName, $email, $name)
Definition: Mail.php:557
if(!isset($_GET['name'])) $name
Definition: log.php:14

◆ addHeader()

addHeader (   $name,
  $value,
  $append = false 
)

Add a custom header to the message

Parameters
string$name
string$value
boolean$append
Returns
Zend_Mail Provides fluent interface
Exceptions
Zend_Mail_Exceptionon attempts to create standard headers
See also
Zend_Mail_Exception

Definition at line 1139 of file Mail.php.

1140  {
1141  $prohibit = array('to', 'cc', 'bcc', 'from', 'subject',
1142  'reply-to', 'return-path',
1143  'date', 'message-id',
1144  );
1145  if (in_array(strtolower($name), $prohibit)) {
1149  #require_once 'Zend/Mail/Exception.php';
1150  throw new Zend_Mail_Exception('Cannot set standard header from addHeader()');
1151  }
1152 
1153  $value = $this->_filterOther($value);
1154  $value = $this->_encodeHeader($value);
1155  $this->_storeHeader($name, $value, $append);
1156 
1157  return $this;
1158  }
_filterOther($data)
Definition: Mail.php:1251
_encodeHeader($value)
Definition: Mail.php:502
$value
Definition: gender.phtml:16
_storeHeader($headerName, $value, $append=false)
Definition: Mail.php:525
if(!isset($_GET['name'])) $name
Definition: log.php:14

◆ addTo()

addTo (   $email,
  $name = '' 
)

Adds To-header and recipient, $email can be an array, or a single string address

Parameters
string | array$email
string$name
Returns
Zend_Mail Provides fluent interface

Definition at line 574 of file Mail.php.

575  {
576  if (!is_array($email)) {
577  $email = array($name => $email);
578  }
579 
580  foreach ($email as $n => $recipient) {
581  $this->_addRecipientAndHeader('To', $recipient, is_int($n) ? '' : $n);
582  $this->_to[] = $recipient;
583  }
584 
585  return $this;
586  }
$email
Definition: details.phtml:13
_addRecipientAndHeader($headerName, $email, $name)
Definition: Mail.php:557
if(!isset($_GET['name'])) $name
Definition: log.php:14

◆ clearDate()

clearDate ( )

Clears the formatted date from the message

Returns
Zend_Mail Provides fluent interface

Definition at line 1030 of file Mail.php.

1031  {
1032  $this->_date = null;
1033  $this->clearHeader('Date');
1034 
1035  return $this;
1036  }
clearHeader($headerName)
Definition: Mail.php:644

◆ clearDefaultFrom()

static clearDefaultFrom ( )
static

Clears the default sender from the mail

Returns
void

Definition at line 794 of file Mail.php.

795  {
796  self::$_defaultFrom = null;
797  }

◆ clearDefaultReplyTo()

static clearDefaultReplyTo ( )
static

Clears the default ReplyTo-address and -name from the mail

Returns
void

Definition at line 845 of file Mail.php.

846  {
847  self::$_defaultReplyTo = null;
848  }

◆ clearDefaultTransport()

static clearDefaultTransport ( )
static

Clear the default transport property

Definition at line 203 of file Mail.php.

204  {
205  self::$_defaultTransport = null;
206  }

◆ clearFrom()

clearFrom ( )

Clears the sender from the mail

Returns
Zend_Mail Provides fluent interface

Definition at line 746 of file Mail.php.

747  {
748  $this->_from = null;
749  $this->clearHeader('From');
750 
751  return $this;
752  }
clearHeader($headerName)
Definition: Mail.php:644

◆ clearHeader()

clearHeader (   $headerName)

Clear header from the message

Parameters
string$headerName
Returns
Zend_Mail Provides fluent inter

Definition at line 644 of file Mail.php.

645  {
646  if (isset($this->_headers[$headerName])){
647  unset($this->_headers[$headerName]);
648  }
649  return $this;
650  }

◆ clearMessageId()

clearMessageId ( )

Clears the Message-ID from the message

Returns
Zend_Mail Provides fluent interface

Definition at line 1088 of file Mail.php.

1089  {
1090  $this->_messageId = null;
1091  $this->clearHeader('Message-Id');
1092 
1093  return $this;
1094  }
clearHeader($headerName)
Definition: Mail.php:644

◆ clearRecipients()

clearRecipients ( )

Clears list of recipient email addresses

Returns
Zend_Mail Provides fluent interface

Definition at line 657 of file Mail.php.

658  {
659  $this->_recipients = array();
660  $this->_to = array();
661 
662  $this->clearHeader('To');
663  $this->clearHeader('Cc');
664  $this->clearHeader('Bcc');
665 
666  return $this;
667  }
clearHeader($headerName)
Definition: Mail.php:644

◆ clearReplyTo()

clearReplyTo ( )

Clears the current Reply-To address from the message

Returns
Zend_Mail Provides fluent interface

Definition at line 759 of file Mail.php.

760  {
761  $this->_replyTo = null;
762  $this->clearHeader('Reply-To');
763 
764  return $this;
765  }
clearHeader($headerName)
Definition: Mail.php:644

◆ clearReturnPath()

clearReturnPath ( )

Clears the current Return-Path address from the message

Returns
Zend_Mail Provides fluent interface

Definition at line 913 of file Mail.php.

914  {
915  $this->_returnPath = null;
916  $this->clearHeader('Return-Path');
917 
918  return $this;
919  }
clearHeader($headerName)
Definition: Mail.php:644

◆ clearSubject()

clearSubject ( )

Clears the encoded subject from the message

Returns
Zend_Mail Provides fluent interface

Definition at line 959 of file Mail.php.

960  {
961  $this->_subject = null;
962  $this->clearHeader('Subject');
963 
964  return $this;
965  }
clearHeader($headerName)
Definition: Mail.php:644

◆ createAttachment()

createAttachment (   $body,
  $mimeType = Zend_Mime::TYPE_OCTETSTREAM,
  $disposition = Zend_Mime::DISPOSITION_ATTACHMENT,
  $encoding = Zend_Mime::ENCODING_BASE64,
  $filename = null 
)

Creates a Zend_Mime_Part attachment

Attachment is automatically added to the mail object after creation. The attachment object is returned to allow for further manipulation.

Parameters
string$body
string$mimeType
string$disposition
string$encoding
string$filenameOPTIONAL A filename for the attachment
Returns
Zend_Mime_Part Newly created Zend_Mime_Part object (to allow advanced settings)

Definition at line 465 of file Mail.php.

470  {
471 
472  $mp = new Zend_Mime_Part($body);
473  $mp->encoding = $encoding;
474  $mp->type = $mimeType;
475  $mp->disposition = $disposition;
476  $mp->filename = $filename;
477 
478  $this->addAttachment($mp);
479 
480  return $mp;
481  }
addAttachment(Zend_Mime_Part $attachment)
Definition: Mail.php:443

◆ createMessageId()

createMessageId ( )

Creates the Message-ID

Returns
string

Definition at line 1101 of file Mail.php.

1101  {
1102 
1103  $time = time();
1104 
1105  if ($this->_from !== null) {
1106  $user = $this->_from;
1107  } elseif (isset($_SERVER['REMOTE_ADDR'])) {
1108  $user = $_SERVER['REMOTE_ADDR'];
1109  } else {
1110  $user = getmypid();
1111  }
1112 
1113  $rand = mt_rand();
1114 
1115  if ($this->_recipients !== array()) {
1116  $recipient = array_rand($this->_recipients);
1117  } else {
1118  $recipient = 'unknown';
1119  }
1120 
1121  if (isset($_SERVER["SERVER_NAME"])) {
1122  $hostName = $_SERVER["SERVER_NAME"];
1123  } else {
1124  $hostName = php_uname('n');
1125  }
1126 
1127  return sha1($time . $user . $rand . $recipient) . '@' . $hostName;
1128  }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
$_from
Definition: Mail.php:98
$user
Definition: dummy_user.php:13

◆ getBodyHtml()

getBodyHtml (   $htmlOnly = false)

Return Zend_Mime_Part representing body HTML

Parameters
bool$htmlOnlyWhether to return the body HTML only, or the MIME part; defaults to false, the MIME part
Returns
false|Zend_Mime_Part|string

Definition at line 427 of file Mail.php.

428  {
429  if ($htmlOnly && $this->_bodyHtml) {
430  $body = $this->_bodyHtml;
431  return $body->getContent();
432  }
433 
434  return $this->_bodyHtml;
435  }
$_bodyHtml
Definition: Mail.php:152

◆ getBodyText()

getBodyText (   $textOnly = false)

Return text body Zend_Mime_Part or string

Parameters
bool$textOnlyWhether to return just the body text content or the MIME part; defaults to false, the MIME part
Returns
false|Zend_Mime_Part|string

Definition at line 386 of file Mail.php.

387  {
388  if ($textOnly && $this->_bodyText) {
389  $body = $this->_bodyText;
390  return $body->getContent();
391  }
392 
393  return $this->_bodyText;
394  }
$_bodyText
Definition: Mail.php:146

◆ getCharset()

getCharset ( )

Return charset string

Returns
string

Definition at line 225 of file Mail.php.

226  {
227  return $this->_charset;
228  }
$_charset
Definition: Mail.php:80

◆ getDate()

getDate ( )

Returns the formatted date of the message

Returns
string

Definition at line 1020 of file Mail.php.

1021  {
1022  return $this->_date;
1023  }

◆ getDefaultFrom()

static getDefaultFrom ( )
static

Returns the default sender of the mail

Returns
null|array Null if none was set.

Definition at line 784 of file Mail.php.

785  {
786  return self::$_defaultFrom;
787  }
static $_defaultFrom
Definition: Mail.php:68

◆ getDefaultReplyTo()

static getDefaultReplyTo ( )
static

Returns the default Reply-To Address and Name of the mail

Returns
null|array Null if none was set.

Definition at line 835 of file Mail.php.

836  {
837  return self::$_defaultReplyTo;
838  }
static $_defaultReplyTo
Definition: Mail.php:74

◆ getDefaultTransport()

static getDefaultTransport ( )
static

Gets the default mail transport for all following uses of unittests

Todo:

Allow passing a string to indicate the transport to load

Allow passing in optional options for the transport to load

Definition at line 195 of file Mail.php.

196  {
198  }
static $_defaultTransport
Definition: Mail.php:62

◆ getEncodingOfHeaders()

getEncodingOfHeaders ( )

Return encoding of mail headers

Deprecated:
use getHeaderEncoding() instead
Returns
string

Definition at line 299 of file Mail.php.

300  {
301  return $this->getHeaderEncoding();
302  }
getHeaderEncoding()
Definition: Mail.php:311

◆ getFrom()

getFrom ( )

Returns the sender of the mail

Returns
string

Definition at line 726 of file Mail.php.

727  {
728  return $this->_from;
729  }
$_from
Definition: Mail.php:98

◆ getHeaderEncoding()

getHeaderEncoding ( )

Return the encoding of mail headers

Either Zend_Mime::ENCODING_QUOTEDPRINTABLE or Zend_Mime::ENCODING_BASE64

Returns
string

Definition at line 311 of file Mail.php.

312  {
313  return $this->_headerEncoding;
314  }
$_headerEncoding
Definition: Mail.php:92

◆ getHeaders()

getHeaders ( )

Return mail headers

Returns
array

Definition at line 1165 of file Mail.php.

1166  {
1167  return $this->_headers;
1168  }
$_headers
Definition: Mail.php:86

◆ getMessageId()

getMessageId ( )

Returns the Message-ID of the message

Returns
string

Definition at line 1077 of file Mail.php.

1078  {
1079  return $this->_messageId;
1080  }
$_messageId
Definition: Mail.php:140

◆ getMimeBoundary()

getMimeBoundary ( )

Return the boundary string used for the message

Returns
string

Definition at line 288 of file Mail.php.

289  {
290  return $this->_mimeBoundary;
291  }
$_mimeBoundary
Definition: Mail.php:158

◆ getPartCount()

getPartCount ( )

Return a count of message parts

Returns
integer

Definition at line 488 of file Mail.php.

489  {
490  return count($this->_parts);
491  }

◆ getRecipients()

getRecipients ( )

Return list of recipient email addresses

Returns
array (of strings)

Definition at line 633 of file Mail.php.

634  {
635  return array_keys($this->_recipients);
636  }

◆ getReplyTo()

getReplyTo ( )

Returns the current Reply-To address of the message

Returns
string|null Reply-To address, null when not set

Definition at line 736 of file Mail.php.

737  {
738  return $this->_replyTo;
739  }
$_replyTo
Definition: Mail.php:116

◆ getReturnPath()

getReturnPath ( )

Returns the current Return-Path address of the message

If no Return-Path header is set, returns the value of $_from.

Returns
string

Definition at line 899 of file Mail.php.

900  {
901  if (null !== $this->_returnPath) {
902  return $this->_returnPath;
903  }
904 
905  return $this->_from;
906  }
$_from
Definition: Mail.php:98
$_returnPath
Definition: Mail.php:122

◆ getSubject()

getSubject ( )

Returns the encoded subject of the message

Returns
string

Definition at line 949 of file Mail.php.

950  {
951  return $this->_subject;
952  }
$_subject
Definition: Mail.php:128

◆ getType()

getType ( )

Get content type of the message

Returns
string

Definition at line 263 of file Mail.php.

264  {
265  return $this->_type;
266  }

◆ send()

send (   $transport = null)

Sends this email using the given transport or a previously set DefaultTransport or the internal mail function if no default transport had been set.

Parameters
Zend_Mail_Transport_Abstract$transport
Returns
Zend_Mail Provides fluent interface

Definition at line 1178 of file Mail.php.

1179  {
1180  if ($transport === null) {
1181  if (! self::$_defaultTransport instanceof Zend_Mail_Transport_Abstract) {
1182  #require_once 'Zend/Mail/Transport/Sendmail.php';
1183  $transport = new Zend_Mail_Transport_Sendmail();
1184  } else {
1185  $transport = self::$_defaultTransport;
1186  }
1187  }
1188 
1189  if ($this->_date === null) {
1190  $this->setDate();
1191  }
1192 
1193  if(null === $this->_from && null !== self::getDefaultFrom()) {
1194  $this->setFromToDefaultFrom();
1195  }
1196 
1197  if(null === $this->_replyTo && null !== self::getDefaultReplyTo()) {
1198  $this->setReplyToFromDefault();
1199  }
1200 
1201  $transport->send($this);
1202 
1203  return $this;
1204  }
static $_defaultTransport
Definition: Mail.php:62
setFromToDefaultFrom()
Definition: Mail.php:805
setReplyToFromDefault()
Definition: Mail.php:856
setDate($date=null)
Definition: Mail.php:975

◆ setBodyHtml()

setBodyHtml (   $html,
  $charset = null,
  $encoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE 
)

Sets the HTML body for the message

Parameters
string$html
string$charset
string$encoding
Returns
Zend_Mail Provides fluent interface

Definition at line 404 of file Mail.php.

405  {
406  if ($charset === null) {
407  $charset = $this->_charset;
408  }
409 
410  $mp = new Zend_Mime_Part($html);
411  $mp->encoding = $encoding;
412  $mp->type = Zend_Mime::TYPE_HTML;
413  $mp->disposition = Zend_Mime::DISPOSITION_INLINE;
414  $mp->charset = $charset;
415 
416  $this->_bodyHtml = $mp;
417 
418  return $this;
419  }
const TYPE_HTML
Definition: Mime.php:34
const DISPOSITION_INLINE
Definition: Mime.php:40
$_charset
Definition: Mail.php:80

◆ setBodyText()

setBodyText (   $txt,
  $charset = null,
  $encoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE 
)

Sets the text body for the message.

Parameters
string$txt
string$charset
string$encoding
Returns
Zend_Mail Provides fluent interface

Definition at line 362 of file Mail.php.

363  {
364  if ($charset === null) {
365  $charset = $this->_charset;
366  }
367 
368  $mp = new Zend_Mime_Part($txt);
369  $mp->encoding = $encoding;
370  $mp->type = Zend_Mime::TYPE_TEXT;
371  $mp->disposition = Zend_Mime::DISPOSITION_INLINE;
372  $mp->charset = $charset;
373 
374  $this->_bodyText = $mp;
375 
376  return $this;
377  }
const TYPE_TEXT
Definition: Mime.php:33
const DISPOSITION_INLINE
Definition: Mime.php:40
$_charset
Definition: Mail.php:80

◆ setDate()

setDate (   $date = null)

Sets Date-header

Parameters
int | string | Zend_Date$date
Returns
Zend_Mail Provides fluent interface
Exceptions
Zend_Mail_Exceptionif called subsequent times or wrong date format.
See also
Zend_Mail_Exception
Zend_Mail_Exception
Zend_Mail_Exception

Definition at line 975 of file Mail.php.

976  {
977  if ($this->_date === null) {
978  if ($date === null) {
979  $date = date('r');
980  } else if (is_int($date)) {
981  $date = date('r', $date);
982  } else if (is_string($date)) {
983  $date = strtotime($date);
984  if ($date === false || $date < 0) {
988  #require_once 'Zend/Mail/Exception.php';
989  throw new Zend_Mail_Exception('String representations of Date Header must be ' .
990  'strtotime()-compatible');
991  }
992  $date = date('r', $date);
993  } else if ($date instanceof Zend_Date) {
994  $date = $date->get(Zend_Date::RFC_2822);
995  } else {
999  #require_once 'Zend/Mail/Exception.php';
1000  throw new Zend_Mail_Exception(__METHOD__ . ' only accepts UNIX timestamps, Zend_Date objects, ' .
1001  ' and strtotime()-compatible strings');
1002  }
1003  $this->_date = $date;
1004  $this->_storeHeader('Date', $date);
1005  } else {
1009  #require_once 'Zend/Mail/Exception.php';
1010  throw new Zend_Mail_Exception('Date Header set twice');
1011  }
1012  return $this;
1013  }
_storeHeader($headerName, $value, $append=false)
Definition: Mail.php:525

◆ setDefaultFrom()

static setDefaultFrom (   $email,
  $name = null 
)
static

Sets Default From-email and name of the message

Parameters
string$email
string$nameoptional
Returns
void

Definition at line 774 of file Mail.php.

775  {
776  self::$_defaultFrom = array('email' => $email, 'name' => $name);
777  }
$email
Definition: details.phtml:13
if(!isset($_GET['name'])) $name
Definition: log.php:14

◆ setDefaultReplyTo()

static setDefaultReplyTo (   $email,
  $name = null 
)
static

Sets Default ReplyTo-address and -name of the message

Parameters
string$email
string$nameoptional
Returns
void

Definition at line 825 of file Mail.php.

826  {
827  self::$_defaultReplyTo = array('email' => $email, 'name' => $name);
828  }
$email
Definition: details.phtml:13
if(!isset($_GET['name'])) $name
Definition: log.php:14

◆ setDefaultTransport()

static setDefaultTransport ( Zend_Mail_Transport_Abstract  $transport)
static

Sets the default mail transport for all following uses of Zend_Mail::send();

Todo:

Allow passing a string to indicate the transport to load

Allow passing in optional options for the transport to load

Parameters
Zend_Mail_Transport_Abstract$transport

Definition at line 183 of file Mail.php.

184  {
185  self::$_defaultTransport = $transport;
186  }

◆ setEncodingOfHeaders()

setEncodingOfHeaders (   $encoding)

Set the encoding of mail headers

Deprecated:
Use setHeaderEncoding() instead.
Parameters
string$encoding
Returns
Zend_Mail

Definition at line 323 of file Mail.php.

324  {
325  return $this->setHeaderEncoding($encoding);
326  }
setHeaderEncoding($encoding)
Definition: Mail.php:336

◆ setFrom()

setFrom (   $email,
  $name = null 
)

Sets From-header and sender of the message

Parameters
string$email
string$name
Returns
Zend_Mail Provides fluent interface
Exceptions
Zend_Mail_Exceptionif called subsequent times
See also
Zend_Mail_Exception

Definition at line 677 of file Mail.php.

678  {
679  if (null !== $this->_from) {
683  #require_once 'Zend/Mail/Exception.php';
684  throw new Zend_Mail_Exception('From Header set twice');
685  }
686 
687  $email = $this->_filterEmail($email);
688  $name = $this->_filterName($name);
689  $this->_from = $email;
690  $this->_storeHeader('From', $this->_formatAddress($email, $name), true);
691 
692  return $this;
693  }
$email
Definition: details.phtml:13
_storeHeader($headerName, $value, $append=false)
Definition: Mail.php:525
_filterName($name)
Definition: Mail.php:1232
_filterEmail($email)
Definition: Mail.php:1212
_formatAddress($email, $name)
Definition: Mail.php:1268
if(!isset($_GET['name'])) $name
Definition: log.php:14

◆ setFromToDefaultFrom()

setFromToDefaultFrom ( )

Sets From-name and -email based on the defaults

Returns
Zend_Mail Provides fluent interface
Exceptions
Zend_Mail_Exception

Definition at line 805 of file Mail.php.

805  {
806  $from = self::getDefaultFrom();
807  if($from === null) {
808  #require_once 'Zend/Mail/Exception.php';
809  throw new Zend_Mail_Exception(
810  'No default From Address set to use');
811  }
812 
813  $this->setFrom($from['email'], $from['name']);
814 
815  return $this;
816  }
setFrom($email, $name=null)
Definition: Mail.php:677
static getDefaultFrom()
Definition: Mail.php:784

◆ setHeaderEncoding()

setHeaderEncoding (   $encoding)

Set the encoding of mail headers

Parameters
string$encodingZend_Mime::ENCODING_QUOTEDPRINTABLE or Zend_Mime::ENCODING_BASE64
Returns
Zend_Mail Provides fluent interface
Exceptions
Zend_Mail_Exception
See also
Zend_Mail_Exception

Definition at line 336 of file Mail.php.

337  {
338  $allowed = array(
341  );
342  if (!in_array($encoding, $allowed)) {
346  #require_once 'Zend/Mail/Exception.php';
347  throw new Zend_Mail_Exception('Invalid encoding "' . $encoding . '"');
348  }
349  $this->_headerEncoding = $encoding;
350 
351  return $this;
352  }
const ENCODING_QUOTEDPRINTABLE
Definition: Mime.php:37
const ENCODING_BASE64
Definition: Mime.php:38

◆ setMessageId()

setMessageId (   $id = true)

Sets the Message-ID of the message

Parameters
boolean | string$idtrue :Auto false :No set null :No set string:Sets given string (Angle brackets is not necessary)
Returns
Zend_Mail Provides fluent interface
Exceptions
Zend_Mail_Exception
See also
Zend_Mail_Exception

Definition at line 1049 of file Mail.php.

1050  {
1051  if ($id === null || $id === false) {
1052  return $this;
1053  } elseif ($id === true) {
1054  $id = $this->createMessageId();
1055  }
1056 
1057  if ($this->_messageId === null) {
1058  $id = $this->_filterOther($id);
1059  $this->_messageId = $id;
1060  $this->_storeHeader('Message-Id', '<' . $this->_messageId . '>');
1061  } else {
1065  #require_once 'Zend/Mail/Exception.php';
1066  throw new Zend_Mail_Exception('Message-ID set twice');
1067  }
1068 
1069  return $this;
1070  }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
$id
Definition: fieldset.phtml:14
createMessageId()
Definition: Mail.php:1101
_filterOther($data)
Definition: Mail.php:1251
_storeHeader($headerName, $value, $append=false)
Definition: Mail.php:525

◆ setMimeBoundary()

setMimeBoundary (   $boundary)

Set an arbitrary mime boundary for the message

If not set, Zend_Mime will generate one.

Parameters
string$boundary
Returns
Zend_Mail Provides fluent interface

Definition at line 276 of file Mail.php.

277  {
278  $this->_mimeBoundary = $boundary;
279 
280  return $this;
281  }

◆ setReplyTo()

setReplyTo (   $email,
  $name = null 
)

Set Reply-To Header

Parameters
string$email
string$name
Returns
Zend_Mail
Exceptions
Zend_Mail_Exceptionif called more than one time
See also
Zend_Mail_Exception

Definition at line 703 of file Mail.php.

704  {
705  if (null !== $this->_replyTo) {
709  #require_once 'Zend/Mail/Exception.php';
710  throw new Zend_Mail_Exception('Reply-To Header set twice');
711  }
712 
713  $email = $this->_filterEmail($email);
714  $name = $this->_filterName($name);
715  $this->_replyTo = $email;
716  $this->_storeHeader('Reply-To', $this->_formatAddress($email, $name), true);
717 
718  return $this;
719  }
$email
Definition: details.phtml:13
_storeHeader($headerName, $value, $append=false)
Definition: Mail.php:525
_filterName($name)
Definition: Mail.php:1232
_filterEmail($email)
Definition: Mail.php:1212
_formatAddress($email, $name)
Definition: Mail.php:1268
if(!isset($_GET['name'])) $name
Definition: log.php:14

◆ setReplyToFromDefault()

setReplyToFromDefault ( )

Sets ReplyTo-name and -email based on the defaults

Returns
Zend_Mail Provides fluent interface
Exceptions
Zend_Mail_Exception

Definition at line 856 of file Mail.php.

856  {
857  $replyTo = self::getDefaultReplyTo();
858  if($replyTo === null) {
859  #require_once 'Zend/Mail/Exception.php';
860  throw new Zend_Mail_Exception(
861  'No default Reply-To Address set to use');
862  }
863 
864  $this->setReplyTo($replyTo['email'], $replyTo['name']);
865 
866  return $this;
867  }
static getDefaultReplyTo()
Definition: Mail.php:835
setReplyTo($email, $name=null)
Definition: Mail.php:703

◆ setReturnPath()

setReturnPath (   $email)

Sets the Return-Path header of the message

Parameters
string$email
Returns
Zend_Mail Provides fluent interface
Exceptions
Zend_Mail_Exceptionif set multiple times
See also
Zend_Mail_Exception

Definition at line 876 of file Mail.php.

877  {
878  if ($this->_returnPath === null) {
879  $email = $this->_filterEmail($email);
880  $this->_returnPath = $email;
881  $this->_storeHeader('Return-Path', $email, false);
882  } else {
886  #require_once 'Zend/Mail/Exception.php';
887  throw new Zend_Mail_Exception('Return-Path Header set twice');
888  }
889  return $this;
890  }
$email
Definition: details.phtml:13
_storeHeader($headerName, $value, $append=false)
Definition: Mail.php:525
_filterEmail($email)
Definition: Mail.php:1212

◆ setSubject()

setSubject (   $subject)

Sets the subject of the message

Parameters
string$subject
Returns
Zend_Mail Provides fluent interface
Exceptions
Zend_Mail_Exception
See also
Zend_Mail_Exception

Definition at line 928 of file Mail.php.

929  {
930  if ($this->_subject === null) {
931  $subject = $this->_filterOther($subject);
932  $this->_subject = $this->_encodeHeader($subject);
933  $this->_storeHeader('Subject', $this->_subject);
934  } else {
938  #require_once 'Zend/Mail/Exception.php';
939  throw new Zend_Mail_Exception('Subject set twice');
940  }
941  return $this;
942  }
_filterOther($data)
Definition: Mail.php:1251
_encodeHeader($value)
Definition: Mail.php:502
_storeHeader($headerName, $value, $append=false)
Definition: Mail.php:525

◆ setType()

setType (   $type)

Set content type

Should only be used for manually setting multipart content types.

Parameters
string$typeContent type
Returns
Zend_Mail Implements fluent interface
Exceptions
Zend_Mail_Exceptionfor types not supported by Zend_Mime
See also
Zend_Mail_Exception

Definition at line 239 of file Mail.php.

240  {
241  $allowed = array(
245  );
246  if (!in_array($type, $allowed)) {
250  #require_once 'Zend/Mail/Exception.php';
251  throw new Zend_Mail_Exception('Invalid content type "' . $type . '"');
252  }
253 
254  $this->_type = $type;
255  return $this;
256  }
const MULTIPART_RELATED
Definition: Mime.php:45
$type
Definition: item.phtml:13
const MULTIPART_ALTERNATIVE
Definition: Mime.php:43
const MULTIPART_MIXED
Definition: Mime.php:44

Field Documentation

◆ $_bodyHtml

$_bodyHtml = false
protected

Definition at line 152 of file Mail.php.

◆ $_bodyText

$_bodyText = false
protected

Definition at line 146 of file Mail.php.

◆ $_charset

$_charset = 'iso-8859-1'
protected

Definition at line 80 of file Mail.php.

◆ $_date

$_date = null
protected

Definition at line 134 of file Mail.php.

◆ $_defaultFrom

$_defaultFrom
staticprotected

Definition at line 68 of file Mail.php.

◆ $_defaultReplyTo

$_defaultReplyTo
staticprotected

Definition at line 74 of file Mail.php.

◆ $_defaultTransport

$_defaultTransport = null
staticprotected

Definition at line 62 of file Mail.php.

◆ $_from

$_from = null
protected

Definition at line 98 of file Mail.php.

◆ $_headerEncoding

$_headerEncoding = Zend_Mime::ENCODING_QUOTEDPRINTABLE
protected

Definition at line 92 of file Mail.php.

◆ $_headers

$_headers = array()
protected

Definition at line 86 of file Mail.php.

◆ $_messageId

$_messageId = null
protected

Definition at line 140 of file Mail.php.

◆ $_mimeBoundary

$_mimeBoundary = null
protected

Definition at line 158 of file Mail.php.

◆ $_recipients

$_recipients = array()
protected

Definition at line 110 of file Mail.php.

◆ $_replyTo

$_replyTo = null
protected

Definition at line 116 of file Mail.php.

◆ $_returnPath

$_returnPath = null
protected

Definition at line 122 of file Mail.php.

◆ $_subject

$_subject = null
protected

Definition at line 128 of file Mail.php.

◆ $_to

$_to = array()
protected

Definition at line 104 of file Mail.php.

◆ $_type

$_type = null
protected

Definition at line 164 of file Mail.php.

◆ $hasAttachments

$hasAttachments = false

Definition at line 172 of file Mail.php.


The documentation for this class was generated from the following file: