Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields
Transport Class Reference
Inheritance diagram for Transport:
TransportInterface

Public Member Functions

 __construct (MessageInterface $message, ScopeConfigInterface $scopeConfig, $parameters=null)
 
 sendMessage ()
 
 getMessage ()
 

Data Fields

const XML_PATH_SENDING_SET_RETURN_PATH = 'system/smtp/set_return_path'
 
const XML_PATH_SENDING_RETURN_PATH_EMAIL = 'system/smtp/return_path_email'
 

Detailed Description

Class that responsible for filling some message data before transporting it.

See also
\Zend\Mail\Transport\Sendmail is used for transport

Definition at line 21 of file Transport.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( MessageInterface  $message,
ScopeConfigInterface  $scopeConfig,
  $parameters = null 
)
Parameters
MessageInterface$messageEmail message object
ScopeConfigInterface$scopeConfigCore store config
null | string | array | \Traversable$parametersConfig options for sendmail parameters

Definition at line 49 of file Transport.php.

53  {
54  /* configuration of whether return path should be set or no. Possible values are:
55  * 0 - no
56  * 1 - yes (set value as FROM address)
57  * 2 - use custom value
58  * @see Magento\Config\Model\Config\Source\Yesnocustom
59  */
60  $isSetReturnPath = $scopeConfig->getValue(
61  self::XML_PATH_SENDING_SET_RETURN_PATH,
63  );
64  $returnPathValue = $scopeConfig->getValue(
65  self::XML_PATH_SENDING_RETURN_PATH_EMAIL,
67  );
68 
69  if ($isSetReturnPath == '2' && $returnPathValue !== null) {
70  $parameters .= ' -f' . \escapeshellarg($returnPathValue);
71  }
72 
73  $this->zendTransport = new Sendmail($parameters);
74  $this->message = $message;
75  }

Member Function Documentation

◆ getMessage()

getMessage ( )

Get message

Returns
\Magento\Framework\Mail\MessageInterface
Since
101.0.0

Implements TransportInterface.

Definition at line 94 of file Transport.php.

95  {
96  return $this->message;
97  }

◆ sendMessage()

sendMessage ( )

Send a mail using this transport

Returns
void
Exceptions

Implements TransportInterface.

Definition at line 80 of file Transport.php.

81  {
82  try {
83  $this->zendTransport->send(
84  Message::fromString($this->message->getRawMessage())
85  );
86  } catch (\Exception $e) {
87  throw new MailException(new Phrase($e->getMessage()), $e);
88  }
89  }

Field Documentation

◆ XML_PATH_SENDING_RETURN_PATH_EMAIL

const XML_PATH_SENDING_RETURN_PATH_EMAIL = 'system/smtp/return_path_email'

Configuration path for custom Return-Path email

Definition at line 32 of file Transport.php.

◆ XML_PATH_SENDING_SET_RETURN_PATH

const XML_PATH_SENDING_SET_RETURN_PATH = 'system/smtp/set_return_path'

Configuration path to source of Return-Path and whether it should be set at all

See also
\Magento\Config\Model\Config\Source\Yesnocustom to possible values

Definition at line 27 of file Transport.php.


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