0

i want to check the email sending functionality of my application. I read different articles but non of them were useful. I want to check what emails are generated by my application so i test my application. i tried different tools like Test Mail Server Tool, smtp4dev etc. But they did not receive emails generated by application.

I want to receive emails content which is sended by the application locally when i call php mail() function.

3
Contributors
2
Replies
18
Views
4 Years
Discussion Span
Last Post by chrishea
2

The really simple solution to something like this would be to just create a wrapper function around whatever method you are using to send the emails, and use that to redirect the email. For example:

function mail_wrapper($to, $subject, $message, $additional_headers, $additional_params)
{
    // If the application is in debug mode, redirect the mail
    // to a tester account.
    if (defined("DEBUG") && DEBUG === true) {
        $to = "tester@example.com";
    }

    return mail($to, $subject, $message, $additional_headers, $additional_params);
}

The same concept would work just as well for more advanced libraries like PHPMailer and Swift Mailer; you would just have to override them or create initialization functions for them that can modify the receiving addresses.

Edited by Atli

0

Are you trying to send emails from a local test server or from a proper "production" server. A local test server isn't normally set up to allow sending of emails.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.