Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Databases

Which skills for timed database emails?

I've built a basic website where people write letters which are automatically stored in an SQL database (futurepostbox.com). At present I manually email these letters back to people 12 months later, but I would like to build in the capacity for these letters to be automatically sent.

I've no idea of where to even start with this, so I was wondering if anyone has any recommendations of Treehouse courses that address is / other resources I that might help with this. OR, are there specific tools I should be looking into? OR, is my basic HTML, CSS, JS, SQL setup just not the right approach for this and I need to look into completely different architecture for the site?

Any advice or insights would be greatly appreciated.

How are you storing user input to the database? Whatever language you input user data to the database with is likely the language that you'll use to retrieve that data, format it into an email, and send it. I've seen it done with Perl, but I'm sure it can be done with any backend programming language (though some may be more complicated than others). I don't believe it can be done with only JavaScript and SQL. Or, if you're using SQL Server, there's a database mail option that could get the trick done for you. I've never used SQL server, so I don't know how that works.

2 Answers

Thanks John! The data is sent to the SQL database from the website with just some simple PHP code (triggered by JS). I'm not familiar with Perl or SQL Server, so I'll look into those as a starting point. Thanks so much :)

Oh, no, you don't need to pick up a new language and work it into your site if you're already using PHP. Whatever language is sending the data to your database can extract it, prep an email and send it. So all you need to do is learn how to do that with PHP.

I've never used PHP, but it looks like there's a pretty simple function to send an email described on this page.

That's just for sending the email, so you'll also need to learn how to retrieve the data and prep it for the email (or maybe you've already learned that.

Thanks John. The biggest issue I have is the "timed" element. I currently have an automated email sent to users at the time they submit their letter (using PHP) just saying thanks. But the main thing I'm looking to solve is creating an automated messaged 12 months later when the letter is sent back to them.