gpt4 book ai didi

laravel - 如何在 Laravel 中转发电子邮件?

转载 作者:行者123 更新时间:2023-12-04 17:27:33 25 4
gpt4 key购买 nike

我正在使用 https://github.com/Webklex/laravel-imap从我的邮件服务器检索电子邮件。

现在我需要转发包含所有正文(文本、html、附件)的确切邮件。如何转发电子邮件?

最佳答案

我在做同样的事情,想就使用 Laravel-IMAP 获取电子邮件然后转发它们给出更具体的答案。

See this answer which helped out a lot.

use Illuminate\Mail\Mailable;

public function build()
{
$this->view('emails.emails.received')->with('body', $this->message->getHTMLBody())
->from($this->message->getFrom()->first()->mail, $this->message->getFrom()->first()->personal)
->to('<forwarded_email>')
->replyTo($this->message->getReplyTo()->first()->mail, $this->message->getReplyTo()->first()->personal)
->subject($this->message->getSubject());

foreach ($this->message->getAttachments() as $attachment) {
$this->attach($attachment);
}

$this->withSwiftMessage(function ($msg) {
$msg->getHeaders()->addTextHeader('In-Reply-To', $this->message->getMessageId());
$msg->getHeaders()->addTextHeader('references', $this->message->getReferences());
});

return $this;
}

此外 - 我的模板 emails.emails.received 仅包含以下内容:{!! $ body !!

关于laravel - 如何在 Laravel 中转发电子邮件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62329458/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com