首页 > 解决方案 > Laravel mail error: Class 'Swift_StreamFilters_StringReplacementFilter' not found

问题描述

Using Laravel 8. Unable to send mail after contact info inserted into DB.

I cannot find any clues online as to how to resolve this error. Everything works on my machine with MailTrap, but not on the live server. With mail code commented out, it works fine. No typos on email address or password. Same issue posted but no replies.

Error screenshot enter image description here

My .env is configured as follows:

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

Throws this error:

Class 'Swift_StreamFilters_StringReplacementFilter' not found 

When I comment out the mail code, everything works (contact info inserted into DB). What fails is emailing the data from the form saved like this:

$data = Contact::create($validatedAttributes);

Attempting to mail:

Mail::to(request('email'))
     ->send(new ContactForm($data));

The ContactForm mailable instance:

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');
    }
}

The markdown template (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

Everything works in MailTrap but not on the server at InMotion Hosting.

Any assistance to identify my error(s) is appreciated.

标签: laravelemail

解决方案


Error 文件上传错误到主机服务器的结果。


推荐阅读