【发布时间】:2021-03-09 13:25:04
【问题描述】:
使用 Laravel 8。将联系信息插入数据库后无法发送邮件。
我在网上找不到有关如何解决此错误的任何线索。一切都可以在我的机器上使用 MailTrap,但不能在实时服务器上。注释掉邮件代码后,它工作正常。电子邮件地址或密码没有拼写错误。 Same issue posted but no replies.
我的.env配置如下:
MAIL_MAILER=smtp
MAIL_HOST=secure279.inmotionhosting.com
MAIL_PORT=465
MAIL_USERNAME=full_email_address
MAIL_PASSWORD=password
MAIL_ENCRYPTION=SSL
MAIL_FROM_ADDRESS=full_email_address
抛出此错误:
Class 'Swift_StreamFilters_StringReplacementFilter' not found
当我注释掉邮件代码时,一切正常(联系信息插入数据库)。失败的是从这样保存的表单中通过电子邮件发送数据:
$data = Contact::create($validatedAttributes);
正在尝试邮寄:
Mail::to(request('email'))
->send(new ContactForm($data));
ContactForm 可邮寄实例:
class ContactForm extends Mailable
{
use Queueable, SerializesModels;
public $data;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct($data)
{
$this->data = $data;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->markdown('emails.contact-form');
}
}
降价模板(电子邮件/联系表单):
@component('mail::message')
# You received a contact form submission from {{ $data->first_name }}.
Here are the details:
- Name: {{ $data->first_name }} {{ $data->last_name }}
- Email: {{ $data->email }}
- Message: {{ $data->message }}
Thanks,<br>
{{ config('app.name') }}
@endcomponent
在 MailTrap 中一切正常,但在 InMotion Hosting 的服务器上却不行。
感谢您提供任何帮助以识别我的错误。
【问题讨论】: