# Forms: Add subject, CC and BCC

**URL:** <https://discourse.getcockpit.com/t/forms-add-subject-cc-and-bcc/225>\
**Category:** Support\
**Created:** [August 29, 2018, 8:54am UTC](https://discourse.getcockpit.com/t/forms-add-subject-cc-and-bcc/225 "2018-08-29T08:54:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![danailov-z](https://avatars.discourse-cdn.com/v4/letter/d/c2a13f/32.png) [@danailov-z](https://discourse.getcockpit.com/u/danailov-z)\
**Post date:** [August 29, 2018, 8:54am UTC](https://discourse.getcockpit.com/t/forms-add-subject-cc-and-bcc/225/1 "2018-08-29T08:54:17Z")

</div>

Hi guys, can anyone tell me how to add custom subject for the mail coming from the forms. I’ve tried in config.yaml in mailer section, but nothing happens. Same with cc and bcc. Other settings, such as from, from\_name, transport, host, etc. works just fine, as it is in the documentation.

Thanks in advance!

P.S. I am using “Next” branch, as of today.

---

<div class="post-metadata">

**Author:** ![raffaelj](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/raffaelj/32/331_2.png) [@raffaelj](https://discourse.getcockpit.com/u/raffaelj)\
**Post date:** [September 7, 2018, 9:43am UTC](https://discourse.getcockpit.com/t/forms-add-subject-cc-and-bcc/225/2 "2018-09-07T09:43:49Z")

</div>

There is a bug for the mail subject. I currently think about/work on it.

Adding dynamic cc and bcc through the forms settings is complicated right now…

If you want to adjust cc and bcc in config.yaml, you have to write these options as an array:

```auto
# use smtp to send emails
mailer:
    from : contactform@example.com
    transport : smtp
    host : smtphost.provider.com
    user : fancy-username
    password : SuperSavePassword
    port : 587
    auth : true
    encryption: starttls
    cc :
        support@example.com
    bcc :
        admin@example.com

```

---

<div class="post-metadata">

**Author:** ![raffaelj](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/raffaelj/32/331_2.png) [@raffaelj](https://discourse.getcockpit.com/u/raffaelj)\
**Post date:** [September 15, 2018, 10:56am UTC](https://discourse.getcockpit.com/t/forms-add-subject-cc-and-bcc/225/3 "2018-09-15T10:56:28Z")

</div>

It’s fixed now. See this thread for more informations: [Forms - What is the best way to pass mailer arguments? - solved](https://discourse.getcockpit.com/t/forms-what-is-the-best-way-to-pass-mailer-arguments-solved/255)

Now you can add this code to `config/bootstrap.php` or to an addon to change your mail settings:

```php
<?php
$app->on('forms.submit.before', function($form, &$data, $frm, &$options) {
    
    // mail subject
    $options['subject'] = 'custom special mail subject';
    
    // add reply_to
    $options['reply_to'] = trim($data['mail']);
    
    // cc and bcc
    $options['cc'] = ['mail1@example.com', 'mail2@example.com'];
    $options['bcc'] = ['mail1@example.com', 'mail2@example.com'];
    
});

```

Have a look at [lib/Mailer](https://github.com/agentejo/cockpit/blob/master/lib/Mailer.php) and [Forms/bootstrap.php](https://github.com/agentejo/cockpit/blob/master/modules/Forms/bootstrap.php#L297) to see more possible options.

Or try

> **[raffaelj/cockpit\_FormValidation](https://github.com/raffaelj/cockpit_FormValidation)**
>
> Form validator and form builder addon for Cockpit CMS - raffaelj/cockpit\_FormValidation

I added a simple templating system for mail subjects and I’ll add more options for CC, BCC etc. soon.
