The solution is a simple PHP function that you can call with any email address and it will convert it into a unique email address for an existing mailbox. The function will take an email address like realclient@client.com to myaccount+realclient@gmail.com Please note that the testing destination email address needs to support the + operator (ie Gmail).
// Create test email for use in testing mode
function createTestEmail($email) {
$email = preg_replace('/(.*?)@(.*)/', "myaccount+\$1@gmail.com", $email);
return $email;
}
To use the above function simply replace myaccount with your email address's name and gmail.com with your email's domain then put through it any email address your system sends to when you are testing. I would recommend automatically replace any destination address with the results of the function if the URL from $_SERVER['HTTP_HOST'] matches your development domain; this way the process is automatic and you don't need to worry about changing configuration or debugging flags.
2 comments:
Development is always an great thing to work with.
Web Designing Company In Chennai
Interesting to know about it! I have never thought Email testing is so easy as you say.
school websites design
Post a Comment