# Error sending email

**URL:** <https://forum.mautic.org/t/error-sending-email/7515>\
**Category:** Product Support\
**Created:** [February 14, 2017, 1:35pm UTC](https://forum.mautic.org/t/error-sending-email/7515 "2017-02-14T13:35:03Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![andreamarucci](https://avatars.discourse-cdn.com/v4/letter/a/43a26b/32.png) [@andreamarucci](https://forum.mautic.org/u/andreamarucci)\
**Post date:** [February 14, 2017, 1:35pm UTC](https://forum.mautic.org/t/error-sending-email/7515/1 "2017-02-14T13:35:03Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![andreamarucci](https://avatars.discourse-cdn.com/v4/letter/a/43a26b/32.png) [@andreamarucci](https://forum.mautic.org/u/andreamarucci)\
**Post date:** [February 14, 2017, 1:35pm UTC](https://forum.mautic.org/t/error-sending-email/7515/2 "2017-02-14T13:35:03Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![bchiam](https://avatars.discourse-cdn.com/v4/letter/b/bcef8e/32.png) [@bchiam](https://forum.mautic.org/u/bchiam)\
**Post date:** [February 14, 2017, 3:05pm UTC](https://forum.mautic.org/t/error-sending-email/7515/3 "2017-02-14T15:05:36Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![andreamarucci](https://avatars.discourse-cdn.com/v4/letter/a/43a26b/32.png) [@andreamarucci](https://forum.mautic.org/u/andreamarucci)\
**Post date:** [February 14, 2017, 4:44pm UTC](https://forum.mautic.org/t/error-sending-email/7515/4 "2017-02-14T16:44:28Z")

</div>

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

```auto
[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.

---

<div class="post-metadata">

**Author:** ![bchiam](https://avatars.discourse-cdn.com/v4/letter/b/bcef8e/32.png) [@bchiam](https://forum.mautic.org/u/bchiam)\
**Post date:** [February 14, 2017, 4:52pm UTC](https://forum.mautic.org/t/error-sending-email/7515/5 "2017-02-14T16:52:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bchiam](https://avatars.discourse-cdn.com/v4/letter/b/bcef8e/32.png) [@bchiam](https://forum.mautic.org/u/bchiam)\
**Post date:** [February 14, 2017, 4:54pm UTC](https://forum.mautic.org/t/error-sending-email/7515/6 "2017-02-14T16:54:17Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![andreamarucci](https://avatars.discourse-cdn.com/v4/letter/a/43a26b/32.png) [@andreamarucci](https://forum.mautic.org/u/andreamarucci)\
**Post date:** [February 14, 2017, 5:21pm UTC](https://forum.mautic.org/t/error-sending-email/7515/7 "2017-02-14T17:21:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![andreamarucci](https://avatars.discourse-cdn.com/v4/letter/a/43a26b/32.png) [@andreamarucci](https://forum.mautic.org/u/andreamarucci)\
**Post date:** [February 14, 2017, 5:23pm UTC](https://forum.mautic.org/t/error-sending-email/7515/8 "2017-02-14T17:23:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![miguelaguero](https://avatars.discourse-cdn.com/v4/letter/m/8491ac/32.png) [@miguelaguero](https://forum.mautic.org/u/miguelaguero)\
**Post date:** [February 14, 2017, 9:19pm UTC](https://forum.mautic.org/t/error-sending-email/7515/9 "2017-02-14T21:19:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![andreamarucci](https://avatars.discourse-cdn.com/v4/letter/a/43a26b/32.png) [@andreamarucci](https://forum.mautic.org/u/andreamarucci)\
**Post date:** [February 14, 2017, 10:03pm UTC](https://forum.mautic.org/t/error-sending-email/7515/10 "2017-02-14T22:03:21Z")

</div>

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… ☹

---

<div class="post-metadata">

**Author:** ![andreamarucci](https://avatars.discourse-cdn.com/v4/letter/a/43a26b/32.png) [@andreamarucci](https://forum.mautic.org/u/andreamarucci)\
**Post date:** [February 14, 2017, 10:08pm UTC](https://forum.mautic.org/t/error-sending-email/7515/11 "2017-02-14T22:08:38Z")

</div>

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

[https://github.com/mautic/mautic/issues/3383](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](https://github.com/mautic/mautic/pull/3440)

Can someone help?

---

<div class="post-metadata">

**Author:** ![andreamarucci](https://avatars.discourse-cdn.com/v4/letter/a/43a26b/32.png) [@andreamarucci](https://forum.mautic.org/u/andreamarucci)\
**Post date:** [February 14, 2017, 10:23pm UTC](https://forum.mautic.org/t/error-sending-email/7515/12 "2017-02-14T22:23:18Z")

</div>

Ok, solved thanks to the article above.

Edit this file

```auto
app/bundles/EmailBundle/Controller/AjaxController.php
```

replace line 231

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

with

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

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

Thanks a lot to escopecz…

---

<div class="post-metadata">

**Author:** ![bchiam](https://avatars.discourse-cdn.com/v4/letter/b/bcef8e/32.png) [@bchiam](https://forum.mautic.org/u/bchiam)\
**Post date:** [February 15, 2017, 1:45am UTC](https://forum.mautic.org/t/error-sending-email/7515/13 "2017-02-15T01:45:02Z")

</div>

> [@20065:@andreamarucci](#):
>
> I’m on 2.6 so maybe that one is the problem and it’s a shame since Mautic is absolutely fantastic!

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. 🙂

---

<div class="post-metadata">

**Author:** ![bchiam](https://avatars.discourse-cdn.com/v4/letter/b/bcef8e/32.png) [@bchiam](https://forum.mautic.org/u/bchiam)\
**Post date:** [February 15, 2017, 1:47am UTC](https://forum.mautic.org/t/error-sending-email/7515/14 "2017-02-15T01:47:01Z")

</div>

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

[https://github.com/mautic/mautic/issues/3383](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](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. 🙂

---

<div class="post-metadata">

**Author:** ![bchiam](https://avatars.discourse-cdn.com/v4/letter/b/bcef8e/32.png) [@bchiam](https://forum.mautic.org/u/bchiam)\
**Post date:** [February 15, 2017, 1:48am UTC](https://forum.mautic.org/t/error-sending-email/7515/15 "2017-02-15T01:48:14Z")

</div>

> [@20066:@andreamarucci](#):
>
> BTW where can I download 2.5.1? I can reinstall it if only I can found it.

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

---

<div class="post-metadata">

**Author:** ![andreamarucci](https://avatars.discourse-cdn.com/v4/letter/a/43a26b/32.png) [@andreamarucci](https://forum.mautic.org/u/andreamarucci)\
**Post date:** [February 15, 2017, 8:00am UTC](https://forum.mautic.org/t/error-sending-email/7515/16 "2017-02-15T08:00:19Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![bchiam](https://avatars.discourse-cdn.com/v4/letter/b/bcef8e/32.png) [@bchiam](https://forum.mautic.org/u/bchiam)\
**Post date:** [February 15, 2017, 11:56am UTC](https://forum.mautic.org/t/error-sending-email/7515/17 "2017-02-15T11:56:50Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![andreamarucci](https://avatars.discourse-cdn.com/v4/letter/a/43a26b/32.png) [@andreamarucci](https://forum.mautic.org/u/andreamarucci)\
**Post date:** [February 15, 2017, 12:05pm UTC](https://forum.mautic.org/t/error-sending-email/7515/18 "2017-02-15T12:05:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![andreamarucci](https://avatars.discourse-cdn.com/v4/letter/a/43a26b/32.png) [@andreamarucci](https://forum.mautic.org/u/andreamarucci)\
**Post date:** [February 15, 2017, 1:08pm UTC](https://forum.mautic.org/t/error-sending-email/7515/19 "2017-02-15T13:08:13Z")

</div>

Wow, thanks!!!

---

<div class="post-metadata">

**Author:** ![alainarae](https://avatars.discourse-cdn.com/v4/letter/a/c68b51/32.png) [@alainarae](https://forum.mautic.org/u/alainarae)\
**Post date:** [February 19, 2017, 11:51pm UTC](https://forum.mautic.org/t/error-sending-email/7515/20 "2017-02-19T23:51:34Z")

</div>

Gonna give 2.5.1 a shot - thank you FishStix

[Next page](https://forum.mautic.org/t/error-sending-email/7515.md?page=2)
