# Mautic 5.0.0 - Send Email To Contact API 500 error

**URL:** <https://forum.mautic.org/t/mautic-5-0-0-send-email-to-contact-api-500-error/30437>\
**Category:** Product Support\
**Created:** [January 11, 2024, 4:04am UTC](https://forum.mautic.org/t/mautic-5-0-0-send-email-to-contact-api-500-error/30437 "2024-01-11T04:04:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mauticsmit](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mauticsmit/32/14285_2.png) [@mauticsmit](https://forum.mautic.org/u/mauticsmit)\
**Post date:** [January 11, 2024, 4:04am UTC](https://forum.mautic.org/t/mautic-5-0-0-send-email-to-contact-api-500-error/30437/1 "2024-01-11T04:04:28Z")

</div>

**Your software**  
My Mautic version is: v5.0.0  
My PHP version is: 8.1.18  
My Database type and version is: 10.6.15-MariaDB-cll-lve

**Your problem**  
/emails//contact//send throws a 500 error

These errors are showing in the log:

```auto
mautic.CRITICAL: Uncaught PHP Exception TypeError: "Symfony\Component\Mime\Address::__construct(): Argument #1 ($address) must be of type string, null given, called in /home/root/domains/domain.com/public_html/app/bundles/EmailBundle/Helper/MailHelper.php on line 929" at /home/root/domains/domain.com/public_html/vendor/symfony/mime/Address.php line 42 {"exception":"[object] (TypeError(code: 0): Symfony\\Component\\Mime\\Address::__construct(): Argument #1 ($address) must be of type string, null given, called in /home/root/domains/domain.com/public_html/app/bundles/EmailBundle/Helper/MailHelper.php on line 929 at /home/root/domains/domain.com/public_html/vendor/symfony/mime/Address.php:42)"} {"hostname":"domain.com","pid":2834374}

```

Steps I have tried to fix the problem:

I added two extra lines in my MailHelper.php file

```auto

    public function addTo($address, $name = null)
    {
        $this->checkBatchMaxRecipients();

        try {
            $this->logError('Debugging.....'); //TEST CODE
            $this->logError($address); //TEST CODE
            $this->logError($name); //TEST CODE
            $name = $this->cleanName($name);
            $this->message->addTo(new Address($address, $name ?? ''));
            $this->queuedRecipients[$address] = $name;

            return true;
        } catch (\Exception $e) {
            $this->logError($e, 'to');

            return false;
        }
    }

```

And my log looks like this

```auto
[2024-01-11 03:46:33] mautic.ERROR: [MAIL ERROR] Debugging..... [] {"hostname":"domain.com","pid":2834374}
[2024-01-11 03:46:33] mautic.ERROR: [MAIL ERROR] [] {"hostname":"domain.com","pid":2834374}
[2024-01-11 03:46:33] mautic.ERROR: [MAIL ERROR] [] {"hostname":"domain.com","pid":2834374}
[2024-01-11 03:46:33] mautic.CRITICAL: Uncaught PHP Exception TypeError: "Symfony\Component\Mime\Address::__construct(): Argument #1 ($address) must be of type string, null given, called in /home/root/domains/domain.com/public_html/app/bundles/EmailBundle/Helper/MailHelper.php on line 929" at /home/root/domains/domain.com/public_html/vendor/symfony/mime/Address.php line 42 {"exception":"[object] (TypeError(code: 0): Symfony\\Component\\Mime\\Address::__construct(): Argument #1 ($address) must be of type string, null given, called in /home/root/domains/domain.com/public_html/app/bundles/EmailBundle/Helper/MailHelper.php on line 929 at /home/root/domains/domain.com/public_html/vendor/symfony/mime/Address.php:42)"} {"hostname":"domain.com","pid":2834374}

```

Not sure why this is blank and where is this function being called from.

---

<div class="post-metadata">

**Author:** ![silavapi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/silavapi/32/7424_2.png) [@silavapi](https://forum.mautic.org/u/silavapi)\
**Post date:** [January 11, 2024, 9:26am UTC](https://forum.mautic.org/t/mautic-5-0-0-send-email-to-contact-api-500-error/30437/2 "2024-01-11T09:26:09Z")

</div>

Have you set up your DSN provider yet?

---

<div class="post-metadata">

**Author:** ![mauticsmit](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mauticsmit/32/14285_2.png) [@mauticsmit](https://forum.mautic.org/u/mauticsmit)\
**Post date:** [January 11, 2024, 10:04am UTC](https://forum.mautic.org/t/mautic-5-0-0-send-email-to-contact-api-500-error/30437/3 "2024-01-11T10:04:13Z")

</div>

Yes and I am getting the test email.  
I also get the email when I go in to the contact and send the email manually.  
Just running into an issue when its via the API.

---

<div class="post-metadata">

**Author:** ![mauticsmit](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mauticsmit/32/14285_2.png) [@mauticsmit](https://forum.mautic.org/u/mauticsmit)\
**Post date:** [January 11, 2024, 10:15am UTC](https://forum.mautic.org/t/mautic-5-0-0-send-email-to-contact-api-500-error/30437/4 "2024-01-11T10:15:11Z")

</div>

Nevermind, I double checked and it was the wrong contact ID, it should have been 2 instead of 1.

PBECAK not Mautic

---

<div class="post-metadata">

**Author:** ![silavapi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/silavapi/32/7424_2.png) [@silavapi](https://forum.mautic.org/u/silavapi)\
**Post date:** [January 11, 2024, 10:23am UTC](https://forum.mautic.org/t/mautic-5-0-0-send-email-to-contact-api-500-error/30437/5 "2024-01-11T10:23:06Z")

</div>

LOL glad you got to the bottom of it, happens to the best of us! 🤣

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/1X/43c63600fe51440378769136903f1fa2a9a34102.png) [@system](https://forum.mautic.org/u/system)\
**Post date:** [January 12, 2024, 10:23pm UTC](https://forum.mautic.org/t/mautic-5-0-0-send-email-to-contact-api-500-error/30437/6 "2024-01-12T22:23:42Z")

</div>

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.
