Error sending email

Hello, there’s no way to send out email from Mautic. I’ve tried Gmail, Sendgrid and so on with no luck. Looking at the error log I see

Code:
[14-Feb-2017 14:21:15 Europe/Rome] PHP Fatal error: Call to undefined method setApiKey in /home/shifit/test/public_html/mautic/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php on line 291 [14-Feb-2017 14:21:41 Europe/Rome] PHP Fatal error: Call to undefined method setApiKey in /home/shifit/test/public_html/mautic/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php on line 291 [14-Feb-2017 14:22:06 Europe/Rome] PHP Fatal error: Call to undefined method setApiKey in /home/shifit/test/public_html/mautic/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php on line 291 [14-Feb-2017 14:23:43 Europe/Rome] PHP Fatal error: Call to undefined method setApiKey in /home/shifit/test/public_html/mautic/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php on line 291 [14-Feb-2017 14:30:03 Europe/Rome] PHP Fatal error: Call to undefined method setApiKey in /home/shifit/test/public_html/mautic/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php on line 291 [14-Feb-2017 14:30:09 Europe/Rome] PHP Fatal error: Call to undefined method setApiKey in /home/shifit/test/public_html/mautic/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php on line 291 [14-Feb-2017 14:30:27 Europe/Rome] PHP Fatal error: Call to undefined method setApiKey in /home/shifit/test/public_html/mautic/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php on line 291

So probably this is the problem. How can I fix it?

Hello, there’s no way to send out email from Mautic. I’ve tried Gmail, Sendgrid and so on with no luck. Looking at the error log I see

[14-Feb-2017 14:21:15 Europe/Rome] PHP Fatal error: Call to undefined method setApiKey in /home/shifit/test/public_html/mautic/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php on line 291 [14-Feb-2017 14:21:41 Europe/Rome] PHP Fatal error: Call to undefined method setApiKey in /home/shifit/test/public_html/mautic/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php on line 291 [14-Feb-2017 14:22:06 Europe/Rome] PHP Fatal error: Call to undefined method setApiKey in /home/shifit/test/public_html/mautic/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php on line 291 [14-Feb-2017 14:23:43 Europe/Rome] PHP Fatal error: Call to undefined method setApiKey in /home/shifit/test/public_html/mautic/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php on line 291 [14-Feb-2017 14:30:03 Europe/Rome] PHP Fatal error: Call to undefined method setApiKey in /home/shifit/test/public_html/mautic/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php on line 291 [14-Feb-2017 14:30:09 Europe/Rome] PHP Fatal error: Call to undefined method setApiKey in /home/shifit/test/public_html/mautic/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php on line 291 [14-Feb-2017 14:30:27 Europe/Rome] PHP Fatal error: Call to undefined method setApiKey in /home/shifit/test/public_html/mautic/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php on line 291

So probably this is the problem. How can I fix it?

Under Email Settings --> Click test connection, does it work?
If you enter the correct email and password for your SMTP server. It should show as success.

For me, i enable API under API Setting.

Under User/Authentication Settings
Ensure all required are fill in.

API Enabled. When I click on test connection or send email, the spinning wheel stay there forever and nothing happen. Just looked at the server error log and got this

[14-Feb-2017 17:43:05 Europe/Rome] PHP Fatal error:  Call to undefined method setApiKey in /home/shifit/test/public_html/mautic/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php on line 291

but API was set as you suggested.

Check your cpanel and verify the email settings are all correct.

Did you configure your bounce email address?

Monitored Inbox Settings

IMAP host and IMAP username set correctly. Get the information from Cpanel --> Email setting.

Ensure Port and Encryption set accordingly to Cpanel email setting.

Under Bounces --> Folder to check INBOX

Under Unsubscribe Requests --> Folder to check INBOX

BTW which version of Mautic are you using? At the main time do not upgrade to 2.6. Very unstable. Remain at 2.5.1 until the new stable release come out. I’m patiently waiting.

I’m on 2.6 so maybe that one is the problem and it’s a shame since Mautic is absolutely fantastic!

BTW where can I download 2.5.1? I can reinstall it if only I can found it.

@andreamarucci where you able to found a solution to this?

Unfortunately not. Every time I try to send a test email I get that error in the error log so I’m not able to get out of this problem. I’d like to use Mautic but if I’m unable to send email it’s almost useless… :frowning:

I guess that’s a bug on 2.6 as I’ve read this

https://github.com/mautic/mautic/issues/3383

Problem is that I’m not able to understand how and where to apply the fix, if it’s a fix anyway, here

https://github.com/mautic/mautic/pull/3440

Can someone help?

Ok, solved thanks to the article above.

Edit this file

app/bundles/EmailBundle/Controller/AjaxController.php

replace line 231

if (is_callable([$mailer, 'setApiKey'])) {

with

if (method_exists($mailer, 'setApiKey')) {

tried now and the test connection and send test email worked correctly…

Thanks a lot to escopecz…

Then don’t waste time working on it since 2.6 is unstable. Revert backt o 2.5.1 should resolve it and wait for the stable release to be out. :slight_smile:

[quote=20076:@andreamarucci]I guess that’s a bug on 2.6 as I’ve read this

https://github.com/mautic/mautic/issues/3383

Problem is that I’m not able to understand how and where to apply the fix, if it’s a fix anyway, here

https://github.com/mautic/mautic/pull/3440

Can someone help?[/quote]

Yes. 2.6 do not have a bug. Instead it have many many bugs crawling around… haha… Stay at 2.5.1 for the time being first. Waiting patiently for the stable release to be out. :slight_smile:

Try to ask your webhost to restore your past backup of 2.5.1 point where you installed. That is what i did too.

Oh sure but there’s a problem. I’ve not done an upgrade, I’ve just installed the latest release since I’m new on Mautic and I’m just testing it. If someone can tell me where to download 2.5.1 I’ll install it.

I install using Softaculous via cPanel is more stable.

When you install from Softaculous it is v2.6

I have a attachment for 2.5.1 in zip file but i tried to use FTP server to install it but very buggy. End up i use Softaculous and resolved the issue.

I’ve found a zip with 2.5.1 but it’s impossible to install. Unfortunately I don’t have softaculous…

Wow, thanks!!!

Gonna give 2.5.1 a shot - thank you FishStix