agentejo / cockpit

Add content management functionality to any site - plug & play / headless / api-first CMS
http://getcockpit.com
MIT License
5.4k stars 524 forks source link

Allow user to add reply-to option to mailer #1455

Closed Hanawa02 closed 3 years ago

Hanawa02 commented 3 years ago

Added the option to set the reply-to mailer option through parameters in the Forms API.

Closes #1453.

Hanawa02 commented 3 years ago

@aheinze Do you have a plan on when this PR can/will be merged?

aheinze commented 3 years ago

Hi 👋 Thank you for your contribution and sorry for the late reply.

I don't like the idea that you can provide the reply-to via a parameter without further checking. For me it is a security concern here. That's why won't merge this PR, sorry.

But I also understand your approach. You can adjust the functionality easily by creating a config/bootstrap.php file with the following content:

<?php

$app->on('forms.submit.before', function($form, &$data, $frm, &$options) {

    if (COCKPIT_API_REQUEST && $this->param('__replyTo') && filter_var($this->param('__replyTo'), FILTER_VALIDATE_EMAIL)) {
        $options['reply_to'] = $this->param('__replyTo');
    }
});

It is basically binding to the forms.submit.before event and modifying the mailer options before sending the email.

Hope this helps!