在Outlook中,您可以创建带有后续邮件。 创建此类邮件时,您可以设置一个提醒用户的时间。 提醒显示为日历,但未保存在日历中。
我正在将PHP与Symfony一起使用。
我创建了一个SwiftMailerService,其中包含了所需的所有内容。 发送邮件非常有效,但是此提醒只是不想工作,我已经做了很多尝试。
我的服务如下:
private $swift_mailer;
private $templating;
/**
* MailService constructor.
* @param $swift_mailer
*/
public function __construct(\Swift_Mailer $swift_mailer, \Twig_Environment $templating)
{
$this->swift_mailer = $swift_mailer;
$this->templating = $templating;
}
/**
* @param $gruppe
* @param $maintenancewindow
* @throws \Twig_Error_Loader
* @throws \Twig_Error_Runtime
* @throws \Twig_Error_Syntax
*/
public function sendMailToGroup($gruppe, $maintenancewindow)
{
$emails = ['thomas.heiz@pilatus-aircraft.com'];
foreach ($gruppe as $grupp) {
$emails[] = $grupp . '@pilatus-aircraft.com';
}
$message = (new \Swift_Message($maintenancewindow->getMail()->getMailsubject()))
->setFrom('donotreply@pilatus-aircraft.com')
->setTo($emails)
->setPriority(\Swift_Mime_SimpleMessage::PRIORITY_HIGH)
->setDate(new \DateTime())
->setBody(
$this->templating->render(
'send_mail/mail.html.twig', [
'maintenancewindow' => $maintenancewindow,
]
),
'text/html'
);
$now = new \DateTime();
$now->modify('+ 1 hour');
$header = $message->getHeaders();
$header->addTextHeader("X-Message-Flag", "Follow up");
/* $prio = $message->getHeaders();
$prio->addTextHeader('X-Priority', '1');
$impor = $message->getHeaders();
$impor->addTextHeader('Importance', 'high');*/
$header->addTextHeader("Reply-By", $now->format("r"));
$header->addTextHeader("Follow-up-by", $now->format("r"));
/* $attach= $message->getHeaders();
$attach->addTextHeader('X-MS-Has-Attach', 'yes');
$mime= $message->getHeaders();
$mime->addTextHeader('MIME-Version', '1.0');
$scl= $message->getHeaders();
$scl->addTextHeader('X-MS-Exchange-Organization-SCL', '-1');
$lan= $message->getHeaders();
$lan->addTextHeader('Accept-Language', 'de-DE, de-CH, en-US');
$md= $message->getHeaders();
$md->addTextHeader('X-MS-Exchange-Organization-MessageDirectionality', 'Originating');
$as= $message->getHeaders();
$as->addTextHeader('X-MS-Exchange-Organization-AuthSource', 'CHST3V032.pilatus-aircraft.com');
$aa= $message->getHeaders();
$aa->addTextHeader('X-MS-Exchange-Organization-AuthAs', 'Internal');
$am= $message->getHeaders();
$am->addTextHeader('X-MS-Exchange-Organization-AuthMechanism', '04');
$ip= $message->getHeaders();
$ip->addTextHeader('X-Originating-IP', '[172.17.3.239]');
$as= $message->getHeaders();
$as->addTextHeader('X-TM-AS-User-Approved-Sender', 'Yes');
$bs= $message->getHeaders();
$bs->addTextHeader('X-TM-AS-User-Blocked-Sender', 'No');
$content= $message->getHeaders();
$content->addTextHeader('Content-Type', 'text/html');
//$content->addTextHeader('Content-Type', 'application/ms-tnef');
//$content->addTextHeader('Content-Type', 'name="winmail.dat"');
$p2= $message->getHeaders();
$p2->addTextHeader('X-MS-Exchange-Organization-Recipient-P2-Type', 'Bcc');
$representationtype= $message->getHeaders();
$representationtype->addTextHeader('X-MS-Exchange-MessageSentRepresentingType', '1');
$to= $message->getHeaders();
$to->addTextHeader('To', 'Undisclosed recipients:;');
$return= $message->getHeaders();
$return->addTextHeader('Return-Path', 'ict-info@pilatus-aircraft.com');
$autoresponse= $message->getHeaders();
$autoresponse->addTextHeader('X-Auto-Response-Suppress', 'DR, OOF, AutoReply');
$bccfoldering= $message->getHeaders();
$bccfoldering->addTextHeader('X-MS-Exchange-Processed-By-BccFoldering', '15.01.1531.003');*/
$this->swift_mailer->send($message);
}
我的视图如下:
{% block stylesheets %}
<style>
.bold {
font-weight: bold;
}
.red {
color: red;
}
</style>
{% endblock %}
{% block body %}
<h3 class="bold">Sehr geehrte Pilatus Mitarbeitende</h3>
<b>Bitte nehmen Sie untenstehende Informationen zur Kenntnis:</b><br><br>
<table class="col-md-12">
<tr>
{% for title in maintenancewindow.maintenancewindowtranslations %}
{% if title.language == 'de' %}
<td><b>Titel:</b></td>
<td><p> {{ title.title }}</p></td>
{% endif %}
{% endfor %}
</tr>
<tr>
<td><b>Was:</b></td>
<td><p class="red"> {{ maintenancewindow.what.textDe|default }}</p></td>
</tr>
<tr>
<td><b>Was detail:</b></td>
<td><p> {{ maintenancewindow.whatdetail.textDe|default }}</p></td>
</tr>
<tr>
<td><b>Wieso:</b></td>
<td><p> {{ maintenancewindow.why.textDe|default }}</p></td>
</tr>
<tr>
<td><b>Von:</b></td>
<td><p> {{ maintenancewindow.datefrom|date('d.m.Y H:i')|default }}</p></td>
</tr>
<tr>
<td><b>Bis:</b></td>
<td><p> {{ maintenancewindow.dateto|date('d.m.Y H:i')|default }}</p></td>
</tr>
<tr>
<td><b>Verhalten:</b></td>
<td><p> {{ maintenancewindow.behavior.textDe|default }}</p></td>
</tr>
<tr>
<td><b>Information für die Fabrikation:</b></td>
<td><p> {{ maintenancewindow.fabrication.textDe|default }}</p></td>
</tr>
<tr>
<td><b>Nächste Information:</b></td>
<td><p> {{ maintenancewindow.nextinfo.textDe|default }}</p></td>
</tr>
<tr>
<td><b>Kontakt:</b></td>
<td><p> {{ maintenancewindow.mail.contact }}</p></td>
</tr>
</table>
<br>
<p>Sie werden 15 Minuten vor dem Wartungsfenster nochmals darauf hingewiesen, sofern das Mail bis zu diesem Zeitpunkt nicht gelöscht wurde.</p>
<p>Besten Dank für Ihr Verständnis.</p>
<p>Ihre Informatik</p>
<hr>
<b>Please be aware about the following information:</b><br><br>
<table class="col-md-10">
<tr>
{% for title in maintenancewindow.maintenancewindowtranslations %}
{% if title.language == 'en' %}
<td><b>Title:</b></td>
<td><p> {{ title.title }}</p></td>
{% endif %}
{% endfor %}
</tr>
<tr>
<td><b>What:</b></td>
<td><p class="red"> {{ maintenancewindow.what.textEn|default }}</p></td>
</tr>
<tr>
<td><b>What detail:</b></td>
<td><p> {{ maintenancewindow.whatdetail.textEn|default }}</p></td>
</tr>
<tr>
<td><b>Why:</b></td>
<td><p> {{ maintenancewindow.why.textEn|default }}</p></td>
</tr>
<tr>
<td><b>From:</b></td>
<td><p> {{ maintenancewindow.datefrom|date('d.m.Y H:i')|default }}</p></td>
</tr>
<tr>
<td><b>To:</b></td>
<td><p> {{ maintenancewindow.dateto|date('d.m.Y H:i')|default }}</p></td>
</tr>
<tr>
<td><b>Behavior:</b></td>
<td><p> {{ maintenancewindow.behavior.textEn|default }}</p></td>
</tr>
<tr>
<td><b>Information for the Fabrication:</b></td>
<td><p> {{ maintenancewindow.fabrication.textEn|default }}</p></td>
</tr>
<tr>
<td><b>Next Info:</b></td>
<td><p> {{ maintenancewindow.nextinfo.textEn|default }}</p></td>
</tr>
<tr>
<td><b>Contact:</b></td>
<td><p> {{ maintenancewindow.mail.contact }}</p></td>
</tr>
</table>
<br>
<p>You'll be reminded 15 minutes before the maintenance window if the mail was not deleted prior to this time.</p>
<p>Thanks for yout understanding</p>
<p>Your ICT Team</p>
<hr>
{% endblock %}
如您所见,我想用Mailheader修复此问题。 我已经尝试过使用不同头文件的每个Combinatition,但是没有任何效果。
在其他示例中,他们说您应该只设置两个标志,然后它应该起作用。我已经设置了这些标志(X-Message-Flag,Reply-By),但仍然无法使用。
我也已经阅读了关于该问题的几乎每篇文章,但找不到任何好的解决方法。
请帮助我,我花了很多时间在这件事上,如果行不通的话,真是可惜。
谢谢您的回答