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.

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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.