0

I need to send an email notification to an specific address after channel form is submited.. The email address depend on the selection of a field in the form.. I know there's might be a hook for that but i don't know how to use it..

Thanks!

1

After many trial and error (as i'm not a real programmer).. i finally found something that works.. For all the newbies like me.. you need to have an addon.setup.php file and a ext.YOUR-THING.php as explain in the main doc https://docs.expressionengine.com/latest/development/addon_setup_php_file.html and https://docs.expressionengine.com/latest/development/extensions.html.. Then my main script inside my extension file..

function channel_form_submit_entry_end( $cf ) {

    ee()->load->library( 'email' );

    $var = ee()->input->post( 'YOUR-POST-INPUT-NAME', TRUE );
    if ( $var == '123' ) {
        $recipient = 'email1@xyz.com';
    } else {
        $recipient = 'emai2@xyz.com';
    };


    ee()->load->library( 'email' );
    ee()->load->helper( 'text' );

    ee()->email->wordwrap = true;
    ee()->email->mailtype = 'text';
    ee()->email->from( 'email@xys.com' );
    ee()->email->to( $recipient );
    ee()->email->subject( 'YOUR SUBJECT' );
    ee()->email->message( entities_to_ascii( 'YOUR BODY MESSAGE' ) );
    ee()->email->Send();

}

I know it may not be the cleanest script by it works!.. If someone wish to clean this.. please feel free!

| improve this answer | |
0

There is a hook. Find details here:

https://docs.expressionengine.com/latest/development/extension_hooks/module/channel_form/index.html#channel-form-submit-entry-end

All you have to do this is to create an extension file. Initialize email library. You can find fields data in 'parameter you passed in function' or in POST.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.