class Swift_SmtpTransport does not exist

Hi,

I’m getting the error message “class Swift_SmtpTransport does not exist” when trying to send an email. Using the same configuration in a local Windows environment works fine, but in production environment (Ubuntu linux) generates the error.

main-local component is configured this way:

    'mailer' => [


        'class' => 'yii\swiftmailer\Mailer',


        'viewPath' => '@common/mail',


        'useFileTransport'=>false,


        'transport' => [


            'class' => 'Swift_SmtpTransport',


            'host' => 'smtp.sendgrid.net',


            'username' => 'xxxx',


            'password' => 'xxxx',


            'port' => '587',


            'encryption' => 'tls',


        ],


    ],

It is really common, when moving from Windows to Linux, to run into case-sensivity errors.

First, check that ‘common/mail’ is indeed ‘common/mail’ and not ‘common/Mail’, etc.

Thanks, but it’s correct. ‘common/mail’ does exists in both environments.

PHP 7 can make any difference? is there a specific package that should be installed?

Try this




'transport' => [

	'class' => 'Swift_SmtpTransport',

	'host' => 'ssl://smtp.sendgrid.net',

	'username' => '',

	'password' => '',

	'port' => '465',

],



Or




'transport' => [

	'class' => 'Swift_SmtpTransport',

	'host' => 'tls://smtp.sendgrid.net',

	'username' => '',

	'password' => '',

	'port' => '587',

],



Do you have the following file in your system?


@vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/MailTransport.php

Yes

It seems to be something really weird. I reinstalled the entire environment from scratch and it worked.