【发布时间】:2019-04-09 13:59:48
【问题描述】:
这可能看起来很愚蠢,但我想知道如何测试从 Gmail 发送电子邮件的功能,而不是从命令行发送电子邮件,因为它工作正常。我想如何调用发送电子邮件的函数。我关注了这个tutorial。 我的 config/packages/imap.yaml 是
imap:
connections:
example_connection:
mailbox: "{imap.gmail.com:993/imap/ssl}INBOX"
username: "kadrad26666@gmail.com"
password: "password"
another_connection:
mailbox: "{localhost:143}INBOX"
username: "username"
password: "password"
attachments_dir: "%kernel.root_dir%/../var/imap/attachments"
server_encoding: "UTF-8"
IndexController中我的Index函数是
public function index($name, \Swift_Mailer $mailer) {
$message = (new \Swift_Message('Hello Email'))
->setFrom('kadrad26666@gmail.com')
->setTo('kadrad26666@gmail.com')
->setBody(
$this->renderView(
// templates/emails/registration.html.twig
'emails/registration.html.twig',
array('name' => $name)
),
'text/html'
)
;
$mailer->send($message);
return $this->render('registration.html.twig'); }
我的树枝如下
<div class="box box-solid alert-block">
<div class="box-header">
<h3 class="box-title"></h3>
</div>
<div class="box-body">
{{render( controller('App\\Controller\\IndexController::index("hello")') ) }}
</div>
</div>
我卡在index($name, \Swift_Mailer $mailer)中,应该给什么参数。
【问题讨论】:
标签: php symfony sonata-admin swiftmailer symfony4