dongxiandi8313 2018-06-29 16:09
浏览 49
已采纳

如何在Symfony 4中使用实例正确调用函数

I'm trying to send an email with SMTP in Symfony 4 and I have the following function as per the docs.

public function send_smtp(\Swift_Mailer $mailer)
{
    $message = (new \Swift_Message('Hello Email'))
        ->setFrom('send@example.com')
        ->setTo('MyEmail@gmail.com')
        ->setBody('test email content');
    $mailer->send($message);
}

However, I want to call this function from a different one like

$this->send_smtp();

But it complains about 'No parameters are passed' and

$this->send_smtp(\Swift_Mailer);

also gives the error message

Undefined constant 'Swift_Mailer'

What can be the problem and how could it be solved?

  • 写回答

2条回答 默认 最新

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 Win7电脑开机出现硬件设置已更改
      • ¥15 vba代出现莫须有错误,都是一个个复制下来的为啥出错呢?
      • ¥15 /etc/vsftpd/vsftp.conf配置文件加了一行utf8_filesystem=YES之后,启动vsftpd报错
      • ¥15 W5100可以收广播,但是无法发出广播
      • ¥100 PCD点云排序和分割
      • ¥15 GG-CNN抓取数据集
      • ¥15 C++类和对象,多态性,继承,虚函数虚基类
      • ¥15 使用VS2019和Dev c++按%p输出地址,结果相差很大
      • ¥30 有偿解惑TINA老报错,求解惑
      • ¥15 arduino esp8266 编译问题