Contact plugin ignores environment from settings
Created 6 years ago by emergingdzns

I'm getting this error in the logs:

[2017-06-02 12:26:04] local.ERROR: GuzzleHttp\Exception\ClientException: Client error: `POST https://api.sparkpost.com/api/v1/transmissions` resulted in a `400 Bad Request` response:
{ "errors": [ { "message": "Invalid domain", "description": "Unconfigured Sending Domain <localhost.com> ", "code": "700 (truncated...)
 in /path/to/site/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:111

But in my .env I have MAIL_FROM set to the email address from my site, which is an authorized sender. The notifications module works without error. Any thoughts on how to fix this? Do I really have to edit my config files and hard set the from domain??

emergingdzns  —  6 years ago Best Answer

@ryanthompson Dang you and your sexy magic! Duh. I added .from('emailaddressitshouldcomefromhere') to the plugin twig code and now it works. Duh. Sorry.

piterden  —  6 years ago

Could you show what vars do you have in constants.twig? Can't paste image here, look at slack for it.

emergingdzns  —  6 years ago

Holy WTF?!?! In the source for the contact plugin the from address is hard coded!!!

        call_user_func_array(
            [$this->message, 'from'],
            $parser->parse(
                (array)$this->builder->getOption(
                    'from',
                    $settings->get('streams::server_email', 'noreply@localhost.com')
                ),
                $input
            )
        );

Why would anyone do this? Now I have to fork this damn thing to change it. Ugh.

emergingdzns  —  6 years ago Best Answer

@ryanthompson Dang you and your sexy magic! Duh. I added .from('emailaddressitshouldcomefromhere') to the plugin twig code and now it works. Duh. Sorry.

ryanthompson  —  6 years ago

Ya the DEFAULT setting comes from Settings -> System -> Server Email - however based on your above comments that no-reply could be within an env (should be anyways) as well as the settings default value.

Can you create an issue and reference this thread? I'll knock it out.

ryanthompson  —  6 years ago

PS I challenge you to find a hardcoded anything in my code 😛