• Resolved robertcroydon

    (@robertcroydon)


    Hi All

    Can you please help with an issue causing us to not receive Forminator contact from email enquiries from customers. If the total email size exceeds our service provider limit (40GB which is common), the email bounces and our sales team is not notified of it.

    It is also marked as sent in the ‘Form Submissions’ log so it is not possible for our sales guys to easily check if any were not sent.

    Is there any way to do either of these:

    a) limit the total size of the attachments?
    Forminator allows you to limit the size of any one attachment and prevent the form from being posted with a warning.
    As we need to allow more than one attachment due to the nature of the business, so we just need to same check to apply to the total.

    b) notify us somehow of the failures?

    Any other ideas would be welcome.

    Many thanks

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Dmytro – WPMU DEV Support

    (@wpmudevsupport16)

    Hello @robertcroydon,

    Thank you for the explanation.

    As I understand it, the emails are being sent on the frontend with Forminator, but then blocked at some point due to the file size limitations. And Forminator can’t determine this kind of failure for some reason.

    We have forwarded your questions to the developers, so they’ll try replicating a similar scenario and check if any additional PHP snippet could help in such cases.

    We’ll let you know once we hear from the devs.

    Best Regards,
    Dmytro

    Plugin Support Nithin – WPMU DEV Support

    (@wpmudevsupport11)

    Hi @robertcroydon,

    Could you please try this snippet and then check whether it helps?

    <?php
    
    add_action( 'wp_footer', 'wpmudev_file_size_validator_rules', 9999 );
    function wpmudev_file_size_validator_rules() {
    	global $post;
    	if ( is_a( $post, 'WP_Post' ) && ! has_shortcode( $post->post_content, 'forminator_form' ) ) {
    		return;
    	}
    	?>
    	<script type="text/javascript">
    	jQuery( document ).ready( function($) {
    		setTimeout(function() {
    			$('.forminator-custom-form').trigger('after.load.forminator');
    		},100);
    
    		$(document).on('after.load.forminator', function(e, form_id) {
    			$.validator.addMethod('filesize', function (value, element, param) {
                    var file_length = element.files.length; // get length
                    var items = element.files;
                    var fileSize = 0;
                
                    if ( file_length > 0 ) {
                        for ( var i = 0; i < file_length; i++ ) {
                            fileSize = fileSize+items[i].size; // get file size
                        }
    
                        if ( fileSize > param * 1000000 ) {
                            return false;
                        } else {
                            return true;
                        }
                    }
    			}, 'Maximum file size allowed {0} MB.');
    		});
    	});
    	</script>
    	<?php
    }
    
    add_filter( 'forminator_field_file_validation_rules', 'wpmudev_size_rules_file_upload', 10, 3 );
    function wpmudev_size_rules_file_upload( $rules, $id, $field ) {
        if ( $field['file-type'] == 'multiple' ) {
            $id .= '[]';
            if ( ! empty( $rules ) ) {
    			$start_rule = '"' . $id . '": {' . "\n";
    			$end_rule 	= '"' . $id . '": {' . "\n" . '"filesize": "' . $field['upload-limit'] . '",';
    			$rules 		= str_replace( $start_rule, $end_rule , $rules );
    		}
        }
    	return $rules;
    }
    
    

    You can implement the above code as a mu-plugins. Please check this link on how to implement the above code as a mu-plugins:
    https://wpmudev.com/docs/using-wordpress/installing-wordpress-plugins/#installing-mu-plugins

    Best Regards,

    Nithin

    Plugin Support Nithin – WPMU DEV Support

    (@wpmudevsupport11)

    Hi @robertcroydon,

    Since we haven’t heard from you for a while. I’ll mark this thread as resolved for now. Please feel free to re-open the thread if you need further assistance.

    Regards
    Nithin

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Total attachment size limit causing emails to not be sent without annotification’ is closed to new replies.