Is it possible to put the add-filter()-hook into a function?

Yes, of course:

function my_mail()
{

    add_filter('wp_mail_content_type','set_html_content_type');

    wp_mail();

    remove_filter( 'wp_mail_content_type', 'set_html_content_type' );

}

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)