My mailer controller only works on localhost

Hello, I´m working on a website that has multiple forms with a mailer in each page (1 form in the navigation and 2 forms on the footer). Given that I will only use the controller to send an email I decided to use the default “site.php” controller. The problem is, the code works perfectly fine on my local host, it sends the email, but when I upload my site to my godaddy server it doesn´t do anything.

here is my site.php controller:

<?php
return function($kirby, $pages, $page) {


    //CONTACT

    //DETECTS A POST REQUEST AND A SUBMIT
    if ($kirby->request()->is('POST') && get('submit')) {

        //THIS IS A HIDDEN TYPE FIELD THAT IS IN EVERY FORM TO IDENTIFY EACH ONE
        $type = get('type');

        //INITIALIZE VARIABLES
        $alerts = null;
        $attachments = [];

        //DATA FROM FORM 1
        $dataModal = [
            'name'    => get('name'),
            'project' => get('project'),
            'tel'     => get('tel'),
            'estado'  => get('estado'),
            'otro'    => get('otro'),
            'modelo'  => get('modelo'),
            'help'    => get('help')
        ];

        //DATA FROM FORM 2
        $dataContacto = [
            'name'        => get('name'),
            'email'       => get('email'),
            'tel'         => get('tel'),
            'estado'      => get('estado'),
            'comentarios' => get('comentarios')
        ];

        //DATA FROM FORM 3
        $dataSubscription = [
            'subscriptionName'    => get('subscriptionName'),
            'subscriptionPuesto'  => get('subscriptionPuesto'),
            'subscriptionEmail'   => get('subscriptionEmail'),
            'subscriptionTel'     => get('subscriptionTel'),
            'subscriptionEmpresa' => get('subscriptionEmpresa'),
            'subscriptionGiro'    => get('subscriptionGiro'),
            'subscriptionEstado'  => get('subscriptionEstado'),
            'subscriptionOtro'    => get('subscriptionOtro')
        ];

        //DATA FROM FORM 4
        $dataCatalogo = [
            'catalogo'      => get('catalogo'),
            'catalogoName'  => get('catalogoName'),
            'catalogoEmail' => get('catalogoEmail')
        ];

        //IN HERE I CHECK THE TYPE VARIABLE TO KNOW WHICH FORM IS BEING SUBMITTED

        if($type == 'ContactoModal'){

            if (empty(get('contactoModalWebsite')) === false) {
                go($page->url());
                exit;
            }

            $rules = [ 'name' => ['required', 'min' => 3] ];
            $messages = [ 'name' => 'Por favor escriba un nombre válido.' ];
    
            if ($invalid = invalid($dataModal, $rules, $messages)) {
                $alerts = $invalid;
            }
    
            $uploads = $kirby->request()->files()->get('file');
    
            if (count($uploads) > 3) {
                $alerts[] = 'Solo puedes subir hasta 3 archivos.';
            }
    
            foreach ($uploads as $upload) {
                if ($upload['error'] !== 0) {
                    $alerts[] = 'No se pudo subir tu archivo';   
                } elseif ($upload['size'] > 2000000)  {
                    $alerts[] = $upload['name'] . ' tine un tamaño mayor a 2mb';
                } else {
                    $name     = $upload['tmp_name'];
                    $tmpName  = pathinfo($name);
                    $filename = $tmpName['dirname']. '/'. F::safeName($upload['name']);
                    if (rename($upload['tmp_name'], $filename)) {
                        $name = $filename;
                    }
                    $attachments[] = $name;
                }  
            }
    
            if (empty($alerts)) {
                try {
                    $kirby->email([
                        'template' => 'ContactoModal',
                        'from'     => 'hey@goldensub.com',
                        'to'       => 'david0cabello0@gmail.com',
                        //'to'       => 'alberto.g@goldensub.com',
                        'subject'     => 'Contacto',
                        'data'        => [
                            'name'    => esc($dataModal['name']),
                            'project' => esc($dataModal['project']),
                            'tel'     => esc($dataModal['tel']),
                            'estado'  => esc($dataModal['estado']),
                            'otro'    => esc($dataModal['otro']),
                            'modelo'  => esc($dataModal['modelo']),
                            'help'    => esc($dataModal['help'])
                        ],
                        'attachments' => $attachments
                    ]);
                } catch (Exception $error) {
                    $alerts[] = "El correo no puede ser enviado";
                }
    
                if (empty($alerts) === true) {
                    // $kirby->session()->set([
                    //     'name'      => esc($dataModal['name']),
                    //     'project' => esc($dataModal['project']),
                    //     'tel'     => esc($dataModal['tel']),
                    //     'estado'  => esc($dataModal['estado']),
                    //     'otro'    => esc($dataModal['otro']),
                    //     'modelo'  => esc($dataModal['modelo']),
                    //     'help'    => esc($dataModal['help'])
                    // ]);
                    go('success');
                }
            }

        }
        
        if($type == 'Contacto'){

            if (empty(get('contactoWebsite')) === false) {
                go($page->url());
                exit;
            }

            $rules = [ 'name' => ['required', 'min' => 3] ];
            $messages = [ 'name' => 'Por favor escriba un nombre válido.' ];
    
            if ($invalid = invalid($dataContacto, $rules, $messages)) {
                $alerts = $invalid;
            }
    
            if (empty($alerts)) {
                try {
                    $kirby->email([
                        'template' => 'Contacto',
                        'from'     => 'hey@goldensub.com',
                        'to'       => 'david0cabello0@gmail.com',
                        //'to'       => 'alberto.g@goldensub.com',
                        'subject'     => 'Contacto',
                        'data'        => [
                            'name'        => esc($dataContacto['name']),
                            'email'       => esc($dataContacto['email']),
                            'tel'         => esc($dataContacto['tel']),
                            'estado'      => esc($dataContacto['estado']),
                            'comentarios' => esc($dataContacto['comentarios'])
                        ]
                    ]);
                } catch (Exception $error) {
                    $alerts[] = "El correo no puede ser enviado";
                }
    
                if (empty($alerts) === true) {
                    // $kirby->session()->set([
                    //     'name'        => esc($dataContacto['name']),
                    //     'email'       => esc($dataContacto['email']),
                    //     'tel'         => esc($dataContacto['tel']),
                    //     'estado'      => esc($dataContacto['estado']),
                    //     'comentarios' => esc($dataContacto['comentarios'])
                    // ]);
                    go('success');
                }
            }
            
        }

        if($type == 'Subscription'){

            if (empty(get('subscriptionWebsite')) === false) {
                go($page->url());
                exit;
            }

            $rules = [ 'subscriptionName' => ['required', 'min' => 3] ];
            $messages = [ 'subscriptionName' => 'Por favor escriba un nombre válido.' ];
    
            if ($invalid = invalid($dataSubscription, $rules, $messages)) {
                $alerts = $invalid;
            }
    
            if (empty($alerts)) {
                try {
                    $kirby->email([
                        'template' => 'Subscription',
                        'from'     => 'hey@goldensub.com',
                        'to'       => 'david0cabello0@gmail.com',
                        //'to'       => 'alberto.g@goldensub.com',
                        'subject'     => 'Contacto',
                        'data'        => [
                            'subscriptionName'    => esc($dataSubscription['subscriptionName']),
                            'subscriptionPuesto'  => esc($dataSubscription['subscriptionPuesto']),
                            'subscriptionEmail'   => esc($dataSubscription['subscriptionEmail']),
                            'subscriptionTel'     => esc($dataSubscription['subscriptionTel']),
                            'subscriptionEmpresa' => esc($dataSubscription['subscriptionEmpresa']),
                            'subscriptionGiro'    => esc($dataSubscription['subscriptionGiro']),
                            'subscriptionEstado'  => esc($dataSubscription['subscriptionEstado']),
                            'subscriptionOtro'    => esc($dataSubscription['subscriptionOtro'])
                        ]
                    ]);
                } catch (Exception $error) {
                    $alerts[] = "El correo no puede ser enviado";
                }
    
                if (empty($alerts) === true) {
                    // $kirby->session()->set([
                    //     'subscriptionName'    => esc($dataSubscription['subscriptionName']),
                    //     'subscriptionPuesto'  => esc($dataSubscription['subscriptionPuesto']),
                    //     'subscriptionEmail'   => esc($dataSubscription['subscriptionEmail']),
                    //     'subscriptionTel'     => esc($dataSubscription['subscriptionTel']),
                    //     'subscriptionEmpresa' => esc($dataSubscription['subscriptionEmpresa']),
                    //     'subscriptionGiro'    => esc($dataSubscription['subscriptionGiro']),
                    //     'subscriptionEstado'  => esc($dataSubscription['subscriptionEstado']),
                    //     'subscriptionOtro'    => esc($dataSubscription['subscriptionOtro'])
                    // ]);
                    go('success');
                }
            }
        }

        if($type == 'Catalogo'){

            if (empty(get('catalogoWebsite')) === false) {
                go($page->url());
                exit;
            }

            $rules = [ 'catalogoName' => ['required', 'min' => 3] ];
            $messages = [ 'catalogoName' => 'Por favor escriba un nombre válido.' ];
    
            if ($invalid = invalid($dataCatalogo, $rules, $messages)) {
                $alerts = $invalid;
            }
    
            if (empty($alerts)) {
                try {
                    $kirby->email([
                        'template' => 'Catalogo',
                        'from'     => 'hey@goldensub.com',
                        'to'       => 'david0cabello0@gmail.com',
                        //'to'       => 'alberto.g@goldensub.com',
                        'subject'     => 'Contacto',
                        'data'        => [
                            'catalogo'      => esc($dataCatalogo['catalogo']),
                            'catalogoName'  => esc($dataCatalogo['catalogoName']),
                            'catalogoEmail' => esc($dataCatalogo['catalogoEmail'])
                        ]
                    ]);
                } catch (Exception $error) {
                    $alerts[] = "El correo no puede ser enviado";
                }
    
                if (empty($alerts) === true) {
                    // $kirby->session()->set([
                    //     'catalogo'      => esc($dataCatalogo['catalogo']),
                    //     'catalogoName'  => esc($dataCatalogo['catalogoName']),
                    //     'catalogoEmail' => esc($dataCatalogo['catalogoEmail'])
                    // ]);
                    go('success');
                }
            }
        }
        
    }

    return [
        'alerts'           => $alerts ?? null,
        'dataModal'        => $dataModal   ?? false,
        'dataContacto'     => $dataContacto   ?? false,
        'dataSubscription' => $dataSubscription   ?? false,
        'dataCatalogo'     => $dataCatalogo   ?? false
    ];
};

Have you debugged where it fails? Does it go into the catch part and output an alert?

What about the template file name, do you really use an uppercase first letter for the file name (we generally suggest using only lowercase for all file names).

Hi, thank you for responding! Actually it was the lowercase, I changed the email template names to all lowercase and now it works. Thank you!