Contact Form sends duplicate emails
-
Two or three emails at the same time, from one submission.
-
I can’t seem to be able to reproduce the issue on my end.
Does this happen for every single form submission? Does this seem like a reliable behaviour (always 2, or always 3 emails?)?
Could you also let me know what other plugins are currently active on your site?
Thanks!
I Have the same issue, one submission with 3 to up 10 e-mails in my inbox.
Using plugin smtp to use sendgrid .@shimmoo What happens when you revert to using your server’s mailing functions? Do you experience similar issues?
My server does not have a native mail() function configured, are one VM on google hosted website.
I tried wipe plugin files, reinstall, use other smtp mail.
And with no other plugin active, no other theme than default theme active, the spin continues and no error message when blank fields in the form are submited.And the mail are submited when the fields are filled properly.
When submit a test e-mail from plugin WP-Mail-SMTP or SMTP the e-mail sending process are fast and normal. But in the last week we are having this issue with the e-mails, but before it all was normal.
Thanks for the extra details. What happens with other emails sent from your WordPress installation, like password reset emails or comment notifications?
Yes, all e-mails have been sent normally.
I was forced to use another contact form plugin.The strange thing is that it started to occur in the last days.
That’s weird indeed. Did you make any updates that may have triggered that change? Did you update WordPress to version 4.7.1, for example?
Last night a contact submission was sent eight times, and eight duplicate entries in Feedback.
This happened some hours after WordPress was updated to 4.7.3 and just before Jetpack was updated to 4.7, if relevant.
When testing this does not happen. It just happens some times, and with different number of duplicates I also have “Email Log” plugin and can see eight outgoing emails with exact same content, at the same minute. A visitor would probably not be able to submit this eight times since you have to refresh the page to get the form back.
There are other plugins active, but only one interferes with Jetpack. It filters the html of a field to make some checkboxes, and alters the message to contain more data:
add_filter( 'grunion_contact_form_field_html', function( $r, $field_label, $id ) { global $post; if ( in_array( $id, [ 513, 1037 ] ) && false !== strpos ( self::KURS_FORM_LABEL, $field_label ) ) { // $meta_query = [ // [ 'key' => 'fra_dato', 'value' => date_i18n( 'Y-m-d', strtotime( '-3 weeks' ) ), 'type' => 'DATE', 'compare' => '>' ], // [ 'key' => 'til_dato', 'value' => date_i18n( 'Y-m-d', strtotime( 'now' ) ), 'type' => 'DATE', 'compare' => '>' ], // ]; $kurs_query = new \WP_Query( [ 'post_type' => 'kurs', 'posts_per_page' => 999, // 'post_status' => 'publish', 'meta_query' => $this->meta_query, ] ); $intet = '<label class="grunion-field-label text"><input class="text" name="g' . $id . '-' . sanitize_title( $field_label ) . '" type="text" style="font-weight: normal;" placeholder="Kursnavn og m?ned (ikke planlagt)" /></label>'; if ( $kurs_query->have_posts() ) { usort( $kurs_query->posts, function( $a, $b ) { return strtotime( get_post_meta( $a->ID, 'fra_dato', true ) ) <=> strtotime( get_post_meta( $b->ID, 'fra_dato', true ) ); } ); while ( $kurs_query->have_posts() ) { $kurs_query->the_post(); $fra = strtotime( get_post_meta( $post->ID, 'fra_dato', true ) ); $til = strtotime( get_post_meta( $post->ID, 'til_dato', true ) ); if ( $fra > strtotime( '-4 months' ) && $til <= strtotime( '+5 months' ) ) { $kurs = esc_attr( 'Niv? ' . get_post_meta( $post->ID, 'niv', true )['name'] . ' – ' . get_the_title() . ' – ' . str_replace( 'dag', '', get_post_meta( $post->ID, 'dag', true )['name'] ) . ' ' . get_post_meta( $post->ID, 'fra_kl', true ) . '–' . get_post_meta( $post->ID, 'til_kl', true ) ); $r .= '<label class="grunion-checkbox-multiple-label checkbox-multiple"><input class="checkbox-mulitple" name="g' . $id . '-' . sanitize_title( $field_label ) . '[]" value ="' . $kurs . '" type="checkbox" /> ' . $kurs . ' – start ' . date_i18n( 'j. M', $fra ) . '</label>'; } else { $r .= $intet; } } } else { $r .= $intet; } wp_reset_postdata(); } return $r; }, 10, 3 ); add_filter( 'contact_form_message', function ( $message ) { $messages = explode( '<br /><br />' . PHP_EOL, $message ); $search ='<b>' . self::KURS_FORM_LABEL . ':</b> '; $len = strlen( $search ); foreach ( $messages as $k => $m ) { if ( 0 === strpos( $m, $search ) ) { $kurs = substr( $m, $len ); $kurser = explode( ', ', $kurs ); $kurs = '<ul><li>' . implode( '</li><li>', $kurser ) . '</li></ul>'; $messages[ $k ] = substr( $m, 0, $len ) . $kurs; } } $message = implode( '<br />' . PHP_EOL, $messages ); return $message; } );
PHP 7.0.16
MySQL 5.5.54
Plugin Simple Cache as active
Other plugins: Woocommerce, Mailchimp ….Thanks for the extra details! Do you have a test site where you could see if this happens when you don’t have anything hooked into
grunion_contact_form_field_html
?I run about 50 sites with Jetpack and Contact Form. I have seen this elsewhere, about 6 months ago, not lately, but then only 2 duplicates, no filtering by any plugin involved. When testing there is never a duplicate, as with most of ordinary submissions by visitors. It seems to happen quite randomly, or, maybe, around updates of WordPress or Jetpack.
I have briefly looked at the code for Contact Form (Grunion) but can’t see what could could be the loop making it repeat.
I have asked the client for some statistics on how often this have happened. 6 months ago it happened quite often, but with just two or three duplicate entries/emails. Then I think it has been more rare, until this with eight duplicates. So this is more annoying than severe, and a real mystery.
About 6 to 8 months ago most of my sites was switched to PHP 7. Just saying ??
And one more thing: Using WP Bruiser plugin, which claims to protect Jetpack Contact Forms from spam. Hmm…@shimmoo: You are not, by any chance, using WP Bruiser for security, spam filtering and monitoring?
@knutsp: Not. Only Akismet and Wordfence.
Inspecting the database, table
posts
:- There is is 2 or 3 seconds between each
post_date
andpost_modfied
for each entry, and those fields are identical on each entry - The
post_name
field is different and meaningless random-like
I think: If the loop in question is in PHP and just saves to the database, isn’t 2-3 seconds too much of a delay?
Is it thinkable that a browser could be looping a submission? I will take a look at the access logs, while still fresh…
-
This reply was modified 8 years ago by
Knut Sparhell.
This is really weird. If you have multiple entries in the database as well, it could indeed have something to do with how the forms are submitted. Do you happen to run a specific caching plugin on all those sites, maybe?
Here we have it, from the access log at the time of the duplicates (
/kurs/pamelding
is the page with the contact form):158.58.*.* - - [07/Mar/2017:21:53:55 +0100] "GET /2017/sminkekurs-for-magedansere/ HTTP/1.1" 200 15710 "https://m.facebook.com/" "Mozilla/5.0 (Linux; Android 4.4.4; C5503 Build/10.5.1.A.0.283) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/33.0.0.0 Mobile Safari/537.36 [FB_IAB/FB4A;FBAV/112.0.0.20.70;]" 158.58.*.* - - [07/Mar/2017:21:53:58 +0100] "POST /2017/sminkekurs-for-magedansere/?wc-ajax=get_refreshed_fragments HTTP/1.1" 200 612 "https://example.com/2017/sminkekurs-for-magedansere/" "Mozilla/5.0 (Linux; Android 4.4.4; C5503 Build/10.5.1.A.0.283) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/33.0.0.0 Mobile Safari/537.36 [FB_IAB/FB4A;FBAV/112.0.0.20.70;]" 158.58.*.* - - [07/Mar/2017:21:53:59 +0100] "GET /?gdbc-client=3.1.4-1488920038246 HTTP/1.1" 200 1707 "https://example.com/2017/sminkekurs-for-magedansere/" "Mozilla/5.0 (Linux; Android 4.4.4; C5503 Build/10.5.1.A.0.283) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/33.0.0.0 Mobile Safari/537.36 [FB_IAB/FB4A;FBAV/112.0.0.20.70;]" 158.58.*.* - - [07/Mar/2017:21:55:06 +0100] "GET /kursene/sminkekurs-for-magedansere/ HTTP/1.1" 200 13801 "https://example.com/2017/sminkekurs-for-magedansere/" "Mozilla/5.0 (Linux; Android 4.4.4; C5503 Build/10.5.1.A.0.283) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/33.0.0.0 Mobile Safari/537.36 [FB_IAB/FB4A;FBAV/112.0.0.20.70;]" 158.58.*.* - - [07/Mar/2017:21:55:08 +0100] "GET /?gdbc-client=3.1.4-1488920107931 HTTP/1.1" 200 1707 "https://example.com/kursene/sminkekurs-for-magedansere/" "Mozilla/5.0 (Linux; Android 4.4.4; C5503 Build/10.5.1.A.0.283) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/33.0.0.0 Mobile Safari/537.36 [FB_IAB/FB4A;FBAV/112.0.0.20.70;]" 158.58.*.* - - [07/Mar/2017:21:55:45 +0100] "GET /kurs/pamelding/ HTTP/1.1" 200 13667 "https://example.com/kursene/sminkekurs-for-magedansere/" "Mozilla/5.0 (Linux; Android 4.4.4; C5503 Build/10.5.1.A.0.283) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/33.0.0.0 Mobile Safari/537.36 [FB_IAB/FB4A;FBAV/112.0.0.20.70;]" 158.58.*.* - - [07/Mar/2017:21:55:47 +0100] "GET /?gdbc-client=3.1.4-1488920146187 HTTP/1.1" 200 1707 "https://example.com/kurs/pamelding/" "Mozilla/5.0 (Linux; Android 4.4.4; C5503 Build/10.5.1.A.0.283) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/33.0.0.0 Mobile Safari/537.36 [FB_IAB/FB4A;FBAV/112.0.0.20.70;]" 158.58.*.* - - [07/Mar/2017:21:55:48 +0100] "POST /wp-admin/admin-ajax.php HTTP/1.1" 200 272 "https://example.com/kurs/pamelding/" "Mozilla/5.0 (Linux; Android 4.4.4; C5503 Build/10.5.1.A.0.283) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/33.0.0.0 Mobile Safari/537.36 [FB_IAB/FB4A;FBAV/112.0.0.20.70;]" 158.58.*.* - - [07/Mar/2017:21:58:29 +0100] "POST /kurs/pamelding/ HTTP/1.1" 302 - "https://example.com/kurs/pamelding/" "Mozilla/5.0 (Linux; Android 4.4.4; C5503 Build/10.5.1.A.0.283) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/33.0.0.0 Mobile Safari/537.36 [FB_IAB/FB4A;FBAV/112.0.0.20.70;]" 158.58.*.* - - [07/Mar/2017:21:58:33 +0100] "GET /kurs/pamelding/?contact-form-id=513&contact-form-sent=1640&_wpnonce=a711817156 HTTP/1.1" 200 11623 "https://example.com/kurs/pamelding/" "Mozilla/5.0 (Linux; Android 4.4.4; C5503 Build/10.5.1.A.0.283) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/33.0.0.0 Mobile Safari/537.36 [FB_IAB/FB4A;FBAV/112.0.0.20.70;]" 158.58.*.* - - [07/Mar/2017:21:58:34 +0100] "POST /kurs/pamelding/ HTTP/1.1" 302 - "https://example.com/kurs/pamelding/" "Mozilla/5.0 (Linux; Android 4.4.4; C5503 Build/10.5.1.A.0.283) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/33.0.0.0 Mobile Safari/537.36 [FB_IAB/FB4A;FBAV/112.0.0.20.70;]" 158.58.*.* - - [07/Mar/2017:21:58:36 +0100] "POST /kurs/pamelding/ HTTP/1.1" 302 - "https://example.com/kurs/pamelding/" "Mozilla/5.0 (Linux; Android 4.4.4; C5503 Build/10.5.1.A.0.283) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/33.0.0.0 Mobile Safari/537.36 [FB_IAB/FB4A;FBAV/112.0.0.20.70;]" 158.58.*.* - - [07/Mar/2017:21:58:36 +0100] "POST /kurs/pamelding/ HTTP/1.1" 302 - "https://example.com/kurs/pamelding/" "Mozilla/5.0 (Linux; Android 4.4.4; C5503 Build/10.5.1.A.0.283) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/33.0.0.0 Mobile Safari/537.36 [FB_IAB/FB4A;FBAV/112.0.0.20.70;]" 158.58.*.* - - [07/Mar/2017:21:58:37 +0100] "POST /kurs/pamelding/ HTTP/1.1" 302 - "https://example.com/kurs/pamelding/" "Mozilla/5.0 (Linux; Android 4.4.4; C5503 Build/10.5.1.A.0.283) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/33.0.0.0 Mobile Safari/537.36 [FB_IAB/FB4A;FBAV/112.0.0.20.70;]" 158.58.*.* - - [07/Mar/2017:21:58:41 +0100] "POST /kurs/pamelding/ HTTP/1.1" 302 - "https://example.com/kurs/pamelding/" "Mozilla/5.0 (Linux; Android 4.4.4; C5503 Build/10.5.1.A.0.283) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/33.0.0.0 Mobile Safari/537.36 [FB_IAB/FB4A;FBAV/112.0.0.20.70;]" 158.58.*.* - - [07/Mar/2017:21:58:43 +0100] "POST /kurs/pamelding/ HTTP/1.1" 302 - "https://example.com/kurs/pamelding/" "Mozilla/5.0 (Linux; Android 4.4.4; C5503 Build/10.5.1.A.0.283) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/33.0.0.0 Mobile Safari/537.36 [FB_IAB/FB4A;FBAV/112.0.0.20.70;]" 158.58.*.* - - [07/Mar/2017:21:58:44 +0100] "POST /kurs/pamelding/ HTTP/1.1" 302 - "https://example.com/kurs/pamelding/" "Mozilla/5.0 (Linux; Android 4.4.4; C5503 Build/10.5.1.A.0.283) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/33.0.0.0 Mobile Safari/537.36 [FB_IAB/FB4A;FBAV/112.0.0.20.70;]" 158.58.*.* - - [07/Mar/2017:21:58:44 +0100] "POST /kurs/pamelding/ HTTP/1.1" 302 - "https://example.com/kurs/pamelding/" "Mozilla/5.0 (Linux; Android 4.4.4; C5503 Build/10.5.1.A.0.283) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/33.0.0.0 Mobile Safari/537.36 [FB_IAB/FB4A;FBAV/112.0.0.20.70;]" 158.58.*.* - - [07/Mar/2017:21:58:51 +0100] "GET /kurs/pamelding/?contact-form-id=513&contact-form-sent=1647&_wpnonce=2b019a7b54 HTTP/1.1" 200 11623 "https://example.com/kurs/pamelding/" "Mozilla/5.0 (Linux; Android 4.4.4; C5503 Build/10.5.1.A.0.283) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/33.0.0.0 Mobile Safari/537.36 [FB_IAB/FB4A;FBAV/112.0.0.20.70;]" 158.58.*.* - - [07/Mar/2017:21:58:56 +0100] "GET /?gdbc-client=3.1.4-1488920335121 HTTP/1.1" 200 1707 "https://example.com/kurs/pamelding/?contact-form-id=513&contact-form-sent=1647&_wpnonce=2b019a7b54" "Mozilla/5.0 (Linux; Android 4.4.4; C5503 Build/10.5.1.A.0.283) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/33.0.0.0 Mobile Safari/537.36 [FB_IAB/FB4A;FBAV/112.0.0.20.70;]"
(some GETs for
/wp-content/..
removed, actual site replaced withexample.com
and request IP anonymized)How come? Why the repeated POST requests?
-
This reply was modified 8 years ago by
James Huff.
-
This reply was modified 8 years ago by
Knut Sparhell.
- There is is 2 or 3 seconds between each
- The topic ‘Contact Form sends duplicate emails’ is closed to new replies.