Jump to content

strange wiremail duplicate sending


benbyf
 Share

Recommended Posts

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

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

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

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

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

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

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

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?

  • Like 1
Link to comment
Share on other sites

  • 10 months later...

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

  • 1 month later...

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

  • 4 weeks later...

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

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...