邮件发送后如何获得提供商响应结果。 例如,我通过symfony / mailgun发送消息,并想在发送消息后从提供商那里获取消息uid
def df_column_switch(df, column1, column2):
i = list(df.columns)
a, b = i.index(column1), i.index(column2)
i[b], i[a] = i[a], i[b]
df = df[i]
return df
答案 0 :(得分:2)
面对同样的问题,我想出了以下解决方案:
<?php
namespace MessengerBundle\MessageHandler;
use Symfony\Component\Mailer\Messenger\MessageHandler;
use Symfony\Component\Mailer\Messenger\SendEmailMessage;
use Symfony\Component\Mailer\SentMessage;
use Symfony\Component\Messenger\Handler\MessageHandlerInterface;
class SendEmailMessageHandler implements MessageHandlerInterface
{
/**
* @var MessageHandler
*/
private $defaultHandler;
/**
* SendEmailMessageHandler constructor.
* @param MessageHandler $defaultMessageHandler
*/
public function __construct(MessageHandler $defaultMessageHandler)
{
$this->defaultHandler = $defaultMessageHandler;
}
/**
* @param SendEmailMessage $message
* @return SentMessage|null
*/
public function __invoke(SendEmailMessage $message): ?SentMessage
{
$handler = $this->defaultHandler;
$sentMessage = $handler($message);
//your logic here
return $sentMessage;
}
}
MessengerBundle\MessageHandler\SendEmailMessageHandler:
autowire: true
autoconfigure: true
public: false
mailer.messenger.message_handler:
class: MessengerBundle\MessageHandler\SendEmailMessageHandler
如果这种异步方法不适合您,您可以尝试 this hack 通过向其中添加 getSentMessage 来扩展邮件服务。