sf_*_*anb 5 swiftmailer symfony
我想在我的Symfony2应用程序中发送电子邮件时命名发件人
Administrator <no-reply@app.com>
Run Code Online (Sandbox Code Playgroud)
我尝试过parameters.ini:
mailer_from = {"no-reply@app.com : Administrator"}
Run Code Online (Sandbox Code Playgroud)
似乎可以这样做,因为在SimpleMessage.php中我们有:
/**
* Set the sender of this message.
* This does not override the From field, but it has a higher significance.
* @param string $sender
* @param string $name optional
* @return Swift_Mime_SimpleMessage
*/
public function setSender($address, $name = null)
{
if (!is_array($address) && isset($name))
{
$address = array($address => $name);
}
if (!$this->_setHeaderFieldModel('Sender', (array) $address))
{
$this->getHeaders()->addMailboxHeader('Sender', (array) $address);
}
return $this;
}
Run Code Online (Sandbox Code Playgroud)
我在parameters.ini失败中尝试过的所有事情.你知道我做错了吗?
dmn*_*ptr 17
// Set a single From: address
$message->setFrom('your@address.tld');
// Set a From: address including a name
$message->setFrom(array('your@address.tld' => 'Your Name'));
// Set multiple From: addresses if multiple people wrote the email
$message->setFrom(array(
'person1@example.org' => 'Sender One',
'person2@example.org' => 'Sender Two'
));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7407 次 |
| 最近记录: |