duan47676379 2017-10-16 12:17
浏览 91

Swift Mailer - 异步发送电子邮件

on a project with intensive emailing activity we are creating asynchronnous workflow for posting emails. Workflow consists of 2 steps:

  1. creating the message (we set Subject, From, to, body, attachments), then converting to a string via $mailer->toString() and store into database.

  2. get few latest emails from database and send them out to user(s).

String stored into database is actually valid multipart EML file (e.g. can be open with Outlook) with message headers + body.

QUESTION:

How can I send message converted toString via SwiftMailer using it's transport capabilities?

Thank you.

Example of stored string in the database:

Message-ID: <1803a1a74c7612e43d58a8ca558117f3@refactoring.local>
Date: Mon, 16 Oct 2017 13:50:31 +0200
Subject: Sample subject
From: info@refactoring.local
Reply-To: info@refactoring.local
To: aaa@bbb.cc
MIME-Version: 1.0
Content-Type: multipart/alternative;
 boundary="_=_swift_v4_1508154632_faf5d3b80866048d993d77a62a9e6497_=_"

--_=_swift_v4_1508154632_faf5d3b80866048d993d77a62a9e6497_=_
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

sample body ...

--_=_swift_v4_1508154632_faf5d3b80866048d993d77a62a9e6497_=_
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org=
/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns=3D"http://www.w3.org/1999/xhtml">
<head>
=09<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DUTF-8"=
 />
=09<title>Sample title</title>
=09</head>
<body>
=09=09

=09sample body ...
=09</body>
</html>

--_=_swift_v4_1508154632_faf5d3b80866048d993d77a62a9e6497_=_--
  • 写回答

1条回答 默认 最新

  • dongxi3911 2017-10-16 12:32
    关注

    There's no simple way to convert a with toString serialized message back to an Swift_Message. Instead, you should use the serialize function to convert the Swift_Message you want to store inside the database back to an string.

    $data = serialize($message);
    // store inside database
    // ...
    // later..
    $message = unserialize($message);
    $mailer->send($message);
    
    评论

报告相同问题?

悬赏问题

  • ¥20 要这个数学建模编程的代码 并且能完整允许出来结果 完整的过程和数据的结果
  • ¥15 html5+css和javascript有人可以帮吗?图片要怎么插入代码里面啊
  • ¥30 Unity接入微信SDK 无法开启摄像头
  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow