Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$this->wire('mail')->new() vs. new WireMail() #733

Closed
suntrop opened this issue Oct 23, 2018 · 3 comments
Closed

$this->wire('mail')->new() vs. new WireMail() #733

suntrop opened this issue Oct 23, 2018 · 3 comments

Comments

@suntrop
Copy link

suntrop commented Oct 23, 2018

Short description of the issue

When I create a new message (and send it) with:
$message = $this->wire('mail')->new();
it is first send via WireSMTP module, but the HTML body is totally messed.

When I create a new message (and send it) with:
$message = new WireMail();
it does not send via WireSMTP module, but the HTML body is ok.

Expected behavior

Always send with WireSMTP and well formatted body

Actual behavior

Doesn't send with WireSMTP when using new WireMail()
Messes up message body when using $this->wire('mail')->new()

Optional: Screenshots/Links that demonstrate the issue

messedmail

Optional: Suggestion for a possible fix

No idea, need help

Steps to reproduce the issue

// $m = $this->wire('mail')->new(); // sends via WireSMTP, but messed body
$m = new WireMail(); // sends via mail(), but message is ok
$m->to('test@example.com');
$m->from('me@example.net');
$m->subject('Test Mail');
$m->body('Test');
$m->bodyHTML($body_html);
$m->send();

Setup/Environment

PW 3.0.98

  • ProcessWire version:
  • (Optional) PHP version: 7
  • (Optional) MySQL version: 5.6
  • (Optional) Any 3rd party modules that are installed and could be related to the issue: WireSMTP
@thetuningspoon
Copy link

This is because with new WireMail() you are bypassing the module search that wire('mail')->new() does. new WireMail() tells php that you specifically want an object of the WireMail class, and I don't think there is any way for PW to intercept that and give you an object of a different class instead.

You can also use the wireMail() function (lowercase "w" without the new), and that will work the same way as wire('mail')->new().

@suntrop
Copy link
Author

suntrop commented Oct 26, 2018

Ok, thanks. I thought WireSMTP would sneak in anyway :-) Didn't know the difference, but makes sense.

@jmartsch
Copy link

@suntrop So can this issue be closed? If yes, please close it. Thank you.

@suntrop suntrop closed this as completed Nov 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants