Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make sure that I don't send any email to customers from testing site in php

I have to make the copy of my existing site for testing purposes at home. I have got the permission from the company.

But in the database I have the more than 10,000 customer records with email. I don't want to accidentally send any emails to them while i make some mess with site during various tests.

whats the best way to avoid that

I do need the email functionality for testing other stuff

like image 667
Mirage Avatar asked Nov 30 '12 08:11

Mirage


People also ask

Why should I verify my list before sending an email?

Whether you're sending a cold email campaign or a regular newsletter, the first thing you should do before hitting the “Send” button is to verify the email addresses on your list. By conducting verification, you clean your email list, filtering invalid and fake email addresses that cause bounces and hurt your delivery rate.

Is it safe to send an email to verify an email?

Sending an email to verify someone’s email address can potentially hurt your sender reputation and deliverability. You never know how many emails will bounce. The safest way to verify email addresses is to use email verification tools like Hunter's Email Verifier.

Why do I need to verify email addresses in my database?

To make sure there are no invalid email addresses in your database, you’ll need to verify them. The delivery rate is a metric that indicates how many people received your email. When you send emails, some of them may bounce and, instead of reaching your prospects’ inboxes, get lost on the way to them. Bounces come in two varieties: soft and hard.

Can I safely send email addresses?

You can safely send email addresses if the response is positive. A negative response means the email address doesn’t exist. Whether you're sending a regular newsletter or a cold outreach campaign, you should make sure all of the email addresses on your list are valid. This will help increase your delivery rate and protect your sender reputation.


1 Answers

The most idiot-proof method you can use is often the best for these things as we all have those days where anything that can go wrong will. It's best to be careful, even borderline paranoid, when a mistake could really ruin your day.

Here's a few methods that might work:

Impotent Configuration by Default

The absolutely safest system is to keep the SMTP server configuration for the production server on the production server and only on the production server. Your development copy would have some other SMTP configuration, like to a testing GMail SMTP account. Usually GMail limits you to 500 emails per day on ordinary accounts so you'll quickly hit this limit if you really screw things up somehow.

Replace Customer Emails in Database

Another thing to consider is scrubbing all of the customer emails in your database, removing them and replacing them with [email protected] and [email protected] if you care to actually receive and inspect them, taking advantage of the fact that the + and subsequent content is ignored for delivery to GMail, effectively giving you unlimited potential email addresses.

As an example:

UPDATE customers SET email=CONCAT('mytestaccount+', customer.id, '@gmail.com')

You'll have to customize this to be whatever email address you want. One advantage to doing this is that you won't have a valuable list of customer email addresses sitting on your development drive and any associated back-ups of it. To be thorough you should probably scramble the hashed passwords as well just so the database is basically worthless to potential hackers. Too many times passwords get scraped from backups that aren't secured properly.

Render Customer Emails Undeliverable

The next best approach is to add ".test" to the end of every email in the system you don't want to send so that it will hard bounce instead of going to someone's inbox.

This is basically a one-liner:

UPDATE customers SET email=CONCAT(email, '.test')

Over-Ride Email at Delivery Time

You can always include some conditional logic like where you will deliberately substitute the recipient of the email message. This can be risky because there's a chance that you might disable that switch by accident, though, so as always, be careful.

In practice this looks something like:

if ($i_should_not_spam_customer_accounts_accidentally)
{
  $mail->to = "nobody@nowhere"
}

Use an API Driven Service

Some Mail Service Providers have an API that can help you when testing email messages. I'm a co-founder at PostageApp and the service was designed so you can send messages using an API key that's specifically configured to receive but not deliver emails. Other services like MailGun can be used in a similar fashion.

No Single Point of Failure

It isn't a good feeling being one logical test away from tragedy, though. You should make sure there's several things that have to go wrong before you have a fiasco.

like image 123
tadman Avatar answered Nov 10 '22 07:11

tadman