Jump to content

How to set what WireMail module to use for sending an email?


LAPS
 Share

Recommended Posts

Hi there,

in ProcessWire I've installed two modules for sending emails: WireMail SMTP and WireMail Mailgun.

I would like to use the WireMail Mailgun for sending an email just for a given case.

When I use the following

$mailer = WireMail();
$mailer->from('sender@email.com');
$mailer->to('receiver@email.com');
$mailer->subject('Testing Mailgun');
$mailer->body('Just testing.');
$mailer->send();

then the email is sent by the WireMail SMTP module.

 

How can I send the email using WireMail Mailgun?

Link to comment
Share on other sites

Use the function wireMail() or the $mail->new() to instantiate an E-Mail object, then ProcessWire will automatically look for other WireMail modules and instantiate one of them instead of the default WireMail object.

You can also request a specific WireMail module by specifing it as an option. For example, for the Mailgun module, this should work:

$mailgun = $mail->new(['module' => 'WireMailMailgun']);
$mailgun instanceof WireMailMailgun; // true

See the documentation for $mail->new().

  • Like 4
  • Thanks 1
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...