benbyf Posted May 25, 2021 Share Posted May 25, 2021 Trying to work out why my module is send two emails when it should be sending one. I have a log statement at the end, it only shows up once in the logs where as i'm still recieving two emails!!? Which is why I'm confused: $mail = wireMail(); // set a default email address if none set $mail->to($u->email)->from($this->siteEmail); // all calls can be chained $mail->subject('New Unread message'); $mail->bodyHTML($msg); $numSent = $mail->send(); if($numSent) $this->wire('log')->save('mm_emails', 'New email sent to: ' . $u->email); I'm running PW 3.0.165 Link to comment Share on other sites More sharing options...
apeisa Posted May 25, 2021 Share Posted May 25, 2021 Where is that code? Template or module? Link to comment Share on other sites More sharing options...
benbyf Posted May 25, 2021 Author Share Posted May 25, 2021 Module. class MembersMessaging extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => "Members messaging" ...blah blah ... 'singular' => true, 'requires' => array("PHP>=5.4.0", "ProcessWire>=3.0.1, MembersMessagingProcess"), ); } Link to comment Share on other sites More sharing options...
horst Posted May 26, 2021 Share Posted May 26, 2021 A) Do you use the core WireMail class or one of the WireMail modules? B) Regardless of that, may be there is somewhere (in config or where ever) set a CC or BCC address header? Link to comment Share on other sites More sharing options...
benbyf Posted May 26, 2021 Author Share Posted May 26, 2021 thats the strange thing. the code above is the only place i'm using it, I tried twice to assure I haven't called the function twice (hence the single log message). And the site is a fresh install, no other modules installed. Link to comment Share on other sites More sharing options...
benbyf Posted May 26, 2021 Author Share Posted May 26, 2021 tried, the php mail() function instead and getting the same issue, but still only one log message... Link to comment Share on other sites More sharing options...
Kholja Posted May 26, 2021 Share Posted May 26, 2021 Just to be sure - maybe it's not a PW Issue. Did you check the E-Mail Headers? 1 Link to comment Share on other sites More sharing options...
benbyf Posted May 26, 2021 Author Share Posted May 26, 2021 To: hello@ethicalby.design X-Spam-Level: * Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="==Multipart_Boundary_x4f3b2ef58aaf86a1b8f42e135b6d876fx" X-Spam-Report: * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5009] * 0.0 HTML_MESSAGE BODY: HTML included in message * 0.8 RDNS_NONE Delivered to internal network by a host with no rDNS X-Spam-Status: No, score=1.6 required=5.0 tests=BAYES_50,HTML_MESSAGE, RDNS_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-Score: 1.6 X-Mailer: ProcessWire/WireMail X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.nicegrp.com Return-Path: <site@bristoltechwork.nicegrp.com> Received: from mail.nicegrp.com ([127.0.0.1]) by mail.nicegrp.com (Dovecot) with LMTP id mfEsKtk/rmDfcQAAOdwwgg for <hello@ethicalby.design>; Wed, 26 May 2021 08:33:12 -0400 Received: from PWbox1.default-fqdn.com (unknown [178.62.6.248]) by mail.nicegrp.com (Postfix) with ESMTP id 85EA91464DB for <hello@ethicalby.design>; Wed, 26 May 2021 08:33:12 -0400 (EDT) Received: by PWbox1 (Postfix, from userid 1000) id 4C15C14008C; Wed, 26 May 2021 08:33:12 -0400 (EDT) <20210526123312.4C15C14008C@PWbox1> Delivered-To: <hello@ethicalby.design> Authentication-Results: mail.nicegrp.com; dmarc=none header.from=bristoltechwork.nicegrp.com not clear to me.. Link to comment Share on other sites More sharing options...
wbmnfktr Posted May 26, 2021 Share Posted May 26, 2021 Try logging all outgoing mails with this little helper which is more precise: $wire->addHookAfter('WireMail::send', function($event) { $mail = $event->object; $event->wire('log')->save('sent-mail', "SENT ($event->return of " . count($mail->to) . "), " . "SUBJECT ($mail->subject), " . "TO (" . implode(", ", $mail->to) . "), " . "FROM ($mail->from)" ); }); https://processwire-recipes.com/recipes/logging-outgoing-emails/ What triggers the send function? Link to comment Share on other sites More sharing options...
benbyf Posted May 26, 2021 Author Share Posted May 26, 2021 Thanks for that! Ok I give up, maybe its my server then... I'm seeing only one logged message there too, but reciveing two still. Will try some other email addresses and report back ? Link to comment Share on other sites More sharing options...
rick Posted May 26, 2021 Share Posted May 26, 2021 I doubt it is an email server issue or wiremail issue. The logs show one email sent but yet you receive two. Correct? What email client are you using and do you have any rules defined for that email address? 1 Link to comment Share on other sites More sharing options...
Rluiten Posted March 27, 2022 Share Posted March 27, 2022 Old bump, but strangely I have the same since implementing wireMail. I used to use PHP mail() but that isn't safe anymore so I changed to wireMail() but now I have double mails haha. Link to comment Share on other sites More sharing options...
Alf S. Posted May 6, 2022 Share Posted May 6, 2022 Same, same. I tried WireMail AND standard PHP mail(). Both are sending twice. In my case the code in incuded with HannaCode. And yes, I am checking for a hidden field $input->post->sent ... if the form is sent... ?? Link to comment Share on other sites More sharing options...
Pete Posted May 30, 2022 Share Posted May 30, 2022 Experiencing the same lately, but not with every email sent from the same block of code which is all the more curious as it's the same email, just sometimes it'll send once, sometimes twice. I'm using WireMailSMTP with Postmark but will check it with the WireMailPostmark module when I get a chance to see if it's something in WireMailSMTP (unlikely I'm sure, just ruling things out). Link to comment Share on other sites More sharing options...
Pete Posted May 31, 2022 Share Posted May 31, 2022 Had a bit of time to look into my issue and it's only started since I changed some code, plus that code is run via a Cron job as the guest user so too many variables to check at the moment, but the fault doesn't seem to be in the system or any module at least so that's good. Link to comment Share on other sites More sharing options...
Gideon So Posted May 31, 2022 Share Posted May 31, 2022 Do you check if the form is submitted to avoid double submit of the form?? Gideon Link to comment Share on other sites More sharing options...
Pete Posted May 31, 2022 Share Posted May 31, 2022 It's on a CRON job so not a form, but also it's only happening occasionally, not for every email generated by that function. 100% it's since my new code so it's some weird combination of CRON and something else. Link to comment Share on other sites More sharing options...
MSP01 Posted June 1, 2022 Share Posted June 1, 2022 Is the code in a template file and does that template use pw-regions? I had a problem where a form was defined as variable at the top of a template file outside of the pw-regions, and then echoed inside a region later on on the same file. This caused it send mails twice each time someone used the form. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now