Closed Richi2293 closed 5 years ago
Mock Mailer doesn't actually send e-mails, it mocks sending them so that you can test in an automated way. Take a look at the source code of mock-mailer.php
and you'll see that it sticks "sent" messages in the mock_sent
property:
https://develop.svn.wordpress.org/trunk/tests/phpunit/includes/mock-mailer.php
Then you can use the get_sent
method to retrieve them.
Hi,
is it possible to make sending mail work in phpunit tests?
I have in my code the 'wp_mail' method of wordpress to send emails and I would like to make it work so as to test also sending the emails.
I tried to configure the parameters to send an email with gmail authentication in the file 'tests/bootstrap.php' in this way: (in the method '_manually_load_plugin')
I also tried to send an email with phpmailer and checking this way (if(!$phpmailer->send()) ) return that email is sent but nothing comes in the email box, am I wrong? How can I make sending emails work from these tests? Thanks