本文整理汇总了PHP中Magento\Framework\Mail\Template\TransportBuilder::setReplyTo方法的典型用法代码示例。如果您正苦于以下问题:PHP TransportBuilder::setReplyTo方法的具体用法?PHP TransportBuilder::setReplyTo怎么用?PHP TransportBuilder::setReplyTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Mail\Template\TransportBuilder
的用法示例。
在下文中一共展示了TransportBuilder::setReplyTo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendrequest
/**
* @param \Magento\Framework\DataObject $postObject
*
* @return bool
* @throws \Exception
*/
public function sendrequest($postObject)
{
if (!filter_var($postObject->getData('to'), FILTER_VALIDATE_EMAIL)) {
throw new \Exception($this->_dataHelper->__('Please enter a valid e-mail address.'));
}
if (strlen(trim($postObject->getData('replyto')))) {
if (!filter_var($postObject->getData('replyto'), FILTER_VALIDATE_EMAIL)) {
throw new \Exception($this->_dataHelper->__('Please enter a valid e-mail address (reply to).'));
}
$this->_transportBuilder->setReplyTo(trim($postObject->getData('replyto')));
}
$sender = ['name' => $this->_dataHelper->getStoreConfigData('trans_email/ident_general/name'), 'email' => $this->_dataHelper->getStoreConfigData('trans_email/ident_general/email')];
if (!strlen($sender['email'])) {
throw new \Exception('Please set your shop e-mail address!');
}
$modules = [];
foreach ($this->_moduleLoader->load() as $module) {
if (!in_array($module['name'], $this->_moduleBlacklist)) {
$modules[] = $module['name'];
}
}
natsort($modules);
$payments = $this->_paymentConfig->getActiveMethods();
/** @var \Magento\Framework\App\Config\Data $cfg */
$cfg = $this->_scopePool->getScope(\Magento\Store\Model\ScopeInterface::SCOPE_STORE);
$foreign = array();
$mine = array();
foreach ($payments as $paymentCode => $paymentModel) {
/** @var AbstractPayment $paymentModel */
$method = array('label' => $paymentModel->getTitle(), 'value' => $paymentCode, 'config' => []);
if (preg_match('/^wirecard_/i', $paymentCode)) {
$method['config'] = $cfg->getValue('payment/' . $paymentCode);
$mine[$paymentCode] = $method;
} else {
$foreign[$paymentCode] = $method;
}
}
$versioninfo = new \Magento\Framework\DataObject();
$versioninfo->setData($this->_dataHelper->getVersionInfo());
$transport = $this->_transportBuilder->setTemplateIdentifier('contact_support_email')->setTemplateOptions(['area' => \Magento\Framework\App\Area::AREA_ADMINHTML, 'store' => \Magento\Store\Model\Store::DEFAULT_STORE_ID])->setTemplateVars(['data' => $postObject, 'modules' => $modules, 'foreign' => $foreign, 'mine' => $mine, 'configstr' => $this->_dataHelper->getConfigString(), 'versioninfo' => $versioninfo])->setFrom($sender)->addTo($postObject->getData('to'))->getTransport();
$transport->sendMessage();
return true;
}
示例2: testSetReplyTo
/**
* @covers \Magento\Framework\Mail\Template\TransportBuilder::setReplyTo
*/
public function testSetReplyTo()
{
$this->messageMock->expects($this->once())->method('setReplyTo')->with('replyTo@example.com', 'replyName')->will($this->returnSelf());
$this->builder->setReplyTo('replyTo@example.com', 'replyName');
}