- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我有一个带有 Swift Mailer 的 Silex 应用程序,但似乎没有从 $app['swiftmailer.options']
加载配置。
我在我的 Bootstrap 文件中注册了该服务
$app->register(new SwiftmailerServiceProvider());
在我的配置文件中
$app['swiftmailer.options'] = array(
'host' => 'smtp.mandrillapp.com',
'port' => '587',
'username' => 'MY_USERNAME',
'password' => 'MY_PASSWORD',
'encryption' => null,
'auth_mode' => null
);
然后我发送我的电子邮件
$message = \Swift_Message::newInstance()
->setSubject($this->app['forum_name'] . ' Account Verification')
->setFrom(array('no-reply@domain.com'))
->setTo(array('recipient@example.com'))
->setBody('My email content')
->setContentType("text/html");
$this->app['mailer']->send($message);
发送函数返回 1
但电子邮件从未发送过。但是,当我尝试手动创建 Swift_SmtpTransport
实例时,电子邮件会发送。
$transport = \Swift_SmtpTransport::newInstance('smtp.mandrillapp.com', 587)
->setUsername('MY_USERNAME')
->setPassword('MY_PASSWORD');
...
$mailer = \Swift_Mailer::newInstance($transport);
$mailer->send($message);
所以问题是 $app['swiftmailer.options']
没有被读取或加载。我在这里遗漏了什么吗?
我正在按照 here 中的说明进行操作.
最佳答案
默认情况下,SwiftmailerServiceProvider 使用假脱机传输来排队电子邮件,并在 TERMINATE 阶段(在将响应发送回客户端之后)将它们全部发送出去。如果您不调用 Application->run()
,您将绕过此过程。您的邮件将留在假脱机中,永远不会发送。
如果您想在正常的 Silex 流程之外发送邮件,您可以使用以下命令手动冲洗阀芯
if ($app['mailer.initialized']) {
$app['swiftmailer.spooltransport']
->getSpool()
->flushQueue($app['swiftmailer.transport']);
}
这直接取自 SwiftmailerServiceProvider。
或者你可以简单地关闭假脱机
$app['swiftmailer.use_spool'] = false;
关于php - Silex + Swift Mailer 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28719472/
我有一个 Rails 邮件程序,目前只要用户回复另一个用户的评论,它就会成功发送电子邮件。 (电子邮件发送给被回复的人)。我正在尝试在电子邮件正文中添加一些动态内容,例如回复者的用户名和该用户的评论本
这是我的代码: require 'phpmailertesting/PHPMailerAutoload.php'; $mail = new PHPMailer; //$mail->SMTPDebug
我想获得有关在/etc/aliases 上运行脚本的问题的任何建议。首先,这是我的环境/脚本。 操作系统:centos 6 脚本:python 2.6.6 邮件:sendmail-8.14/dovec
当我在 Rails3 中使用 ActionMailer 时,我试图更好地理解良好的设计模式(如果它有所不同,则为 3.1)。 一般而言,对于 Rails 应用程序,我通常为整个应用程序创建一个邮件程序
我们能否在 PHP 邮件程序中将消息编译并存储为草稿,然后再发送每条消息? 最佳答案 用 PHPMailer 可以做到这一点。在用发送消息通常需要的所有内容配置 PHPMailer 实例后,不要调用
有没有办法将回调函数传递给 Laravel 的邮件程序? 我正在将 Mail 外观与可邮寄类一起使用,该类正在发送附件。我想在发送电子邮件后删除附件形式的存储。 电子邮件作业正在排队 Mail::to
我正在从 nagios 切换到 sensu。我正在使用厨师来自动化这个过程。一切都很好,除了邮件程序,或者实际上,我将它缩小到“管道”,它应该将 json 输出从支票重定向到处理程序。它没有。当我使用
我正在创建一个预订表格作为帮助,但我决定通过域而不是服务器发送邮件。这主要是为了提高安全性并减少响应和数据传输的限制。 过去几天我一直在研究这个,并试图自学如何让它发挥作用。我现在有一个非常简单的工作
这个问题不太可能对任何 future 的访客有帮助;它只与一个小的地理区域、一个特定的时间点或一个非常狭窄的情况相关,通常不适用于互联网的全局受众。如需帮助使这个问题更广泛适用,visit the h
我正在尝试使用 the Mailer Plugin在我的戏里! 2 Java 应用程序。 我按照自述文件中的说明进行操作,但该模块未显示在我的应用程序的依赖项中。 所以当我尝试编译它时 Play !给
我想在电子邮件正文中包含使用 foreach 的结果。当我添加 foreach 语句时,PHP Mailer 似乎只是切断了消息。关于如何在消息正文中包含多个结果有什么想法吗? $mail->Body
我想利用现有的Mailer来自 Jenkins 的插件位于定义管道构建作业的 Jenkinsfile 中。鉴于以下简单的失败脚本,我希望每次构建都会收到一封电子邮件。 stage 'Test' nod
有没有办法拦截对 Play Mailer class 的调用? 我想记录我的应用程序发送的所有电子邮件。我想访问邮件程序方法参数和方法名称,并记录所有这些。 我尝试过使用@With,但我的@Befor
PHP 邮件程序一次发送两封电子邮件,我尝试不循环发送它,只发送一封电子邮件,但结果相同 我在 stackoverflow 上找到了这个但是没有改变任何东西 $mail->SingleTo = tru
我已关注installation steps由django-mailer的存储库提供者提供 但是当我尝试 ./manage.py test mailer 命令时 或./manage.py send_m
首先,我看到了这个问题:Send mail without blocking 'execution' 但是,我需要知道为什么 PHP 不是多线程进程,但如果两个人同时尝试连接却没有问题。 我实际上是通
我正在从数据库表中提取电子邮件地址并遍历它们以发送电子邮件。如果我注释掉 $mailer->send($message); 行,则会发送一封电子邮件,但只发送到表中的最后一行。如果我保留该行,电子邮件
我在下面有以下代码,需要测试在用户被暂停时发送电子邮件。 def suspendClient(client: Client, event: Event): EventResult = {
我最近加入了一个项目,其中每个客户都有自己的自定义 HTML 内容,用于发送给他们客户的电子邮件。 它通过将内容插入带有自定义标签的字符串,然后通过在邮件程序中设置 body 属性来发送,如下所示:
如何在java imap中获取x-mail?我已经编写了一个示例程序,但它运行不正常。我得到空值。我哪里出错了? import com.sun.mail.imap.IMAPFolder; im
我是一名优秀的程序员,十分优秀!