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

Override mailSend for older version of WordPress #29

Closed
rajumsys opened this issue Apr 8, 2016 · 1 comment
Closed

Override mailSend for older version of WordPress #29

rajumsys opened this issue Apr 8, 2016 · 1 comment

Comments

@rajumsys
Copy link
Contributor

rajumsys commented Apr 8, 2016

While investing this issue, I've found that phpMailer invokes sending method differently in older version. phpMailer with wordpress 4.4, invokes "{$this->Mailer}Send".

WordPress 4.4.2

switch ($this->Mailer) {
                case 'sendmail':
                case 'qmail':
                    return $this->sendmailSend($this->MIMEHeader, $this->MIMEBody);
                case 'smtp':
                    return $this->smtpSend($this->MIMEHeader, $this->MIMEBody);
                case 'mail':
                    return $this->mailSend($this->MIMEHeader, $this->MIMEBody);
                default:
                    $sendMethod = $this->Mailer.'Send';
                    if (method_exists($this, $sendMethod)) {
                        return $this->$sendMethod($this->MIMEHeader, $this->MIMEBody);
                    }

                    return $this->mailSend($this->MIMEHeader, $this->MIMEBody);
            }

WordPress 4.2.2

switch ($this->Mailer) {
                case 'sendmail':
                    return $this->sendmailSend($this->MIMEHeader, $this->MIMEBody);
                case 'smtp':
                    return $this->smtpSend($this->MIMEHeader, $this->MIMEBody);
                case 'mail':
                    return $this->mailSend($this->MIMEHeader, $this->MIMEBody);
                default:
                    return $this->mailSend($this->MIMEHeader, $this->MIMEBody);
            }

Specially, notice these two lines differences:
4.4x

default:
   $sendMethod = $this->Mailer.'Send';
    if (method_exists($this, $sendMethod)) {
        return $this->$sendMethod($this->MIMEHeader, $this->MIMEBody);
    }

    return $this->mailSend($this->MIMEHeader, $this->MIMEBody);

4.2x

default:
    return $this->mailSend($this->MIMEHeader, $this->MIMEBody);

We can probably simply override mailSend in addition to custom mailer which should satisfy both version.

@rajumsys rajumsys changed the title Instantiate Mailer properly Override mailSend for older version of WordPress Apr 8, 2016
@rajumsys
Copy link
Contributor Author

rajumsys commented Apr 8, 2016

This has been fixed in v2.2.1

@rajumsys rajumsys closed this as completed Apr 8, 2016
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

1 participant