Jump to content

Include & Bootstrap with WireMail


bblef91
 Share

Recommended Posts

Hi,

You could do something like that, assuming you are on PW-3.

Create a file called testwiremail.php in the root directory and add the following code :

<?php namespace ProcessWire;

include_once ('./index.php'); // bootstrap

try {
    $mail = wireMail();
    $mail->to('someone@domain.com');
    $mail->from('root@mydomain.com', 'My Company');
    $mail->subject('My subject');
    $mail->bodyHTML('My message body');
    $mail->send();
}
catch(\Exception $ex) {
    echo $ex->getMessage();
}

Now you can navigate to http://mydomain.com/testwiremail.php

 

  • Like 1
Link to comment
Share on other sites

just remove the namespace.

The code should be :

<?php 

include_once ('./index.php'); // bootstrap

try {
    $mail = wireMail();
    $mail->to('someone@domain.com');
    $mail->from('root@mydomain.com', 'My Company');
    $mail->subject('My subject');
    $mail->bodyHTML('My message body');
    $mail->send();
}
catch(Exception $ex) {
    echo $ex->getMessage();
}

 

Does it work ?

  • Like 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

×
×
  • Create New...