Send a templated email from a website where the template is hosted elsewhere?
April 1, 2009 10:44 AM   Subscribe

Send a templated email from a website where the template is hosted elsewhere?

I want to setup a website that hosts a templated email form that someone can fill out their name and their friend's email address and it will send the templated email to their friend and fill in the variable of their name so the friend knows who sent it. Standard stuff, I think.

However, I would like to put the actual form itself on a completely different website because on this different website I will have much less access and can only post HTML, CSS, Javascript, etc. and not actually store a template or anything like that.

Is there an easy way to do this? Everything I've seen so far would require both the form and the templated data to be in the same place.
posted by doomtop to Computers & Internet (4 answers total)
You're leaving too much details out to be any help, but try these:

1) Most templating engines have a "load template from file" function as well as something like "load template from variable".

Most programming languages (such as PHP) have a "load from URL" function. I suggest you combine the "load from url" function from your programming environment with the "load template from variable" - or, if your template engine has no "load template from variable" (such is the case with Smarty), fetch the template, put it in a temporary file (which *all* programming environments will have) and tell the template engine to get the template there.

But all that depends on which language and template engine you have available

2) if all you have on the website is static html, you're never going to send mail from that website anyway, so you'll end up with static html that reads like this:

<form action="">
<input type=text .. .etc >

and that means putting all the programming and mail-sending logic on the server that *has* the template.
posted by DreamerFi at 11:15 AM on April 1, 2009

@DreamerFi: Thanks, the second part is what I'm trying to do I think. I want all the programming and logic and template on one server and the actual basic form itself on a different one.

What details am I leaving out? I would be happy to give more details if it helps get answers! : ) I don't have a template engine or anything like that already, I'm really looking for ideas there.
posted by doomtop at 11:44 AM on April 1, 2009

Well, if you're picking 2, then you're not missing anything. Just make the html form in any way you want, and just let the form action point to the server where you do your programming. And, if you don't have any template engine ready, just google for your favorite programming language and a mail template - for php there are plenty to choose form, and just pick the one you'll be most comfortable with.

Because the most important thing is - with having the form action point to the second server, you've just broken the big problem in your original question: "Everything I've seen so far would require both the form and the templated data to be in the same place" simply isn't true any more.
posted by DreamerFi at 1:00 PM on April 1, 2009

(my email is in my profile, feel free to mail me once you try to implement this and run into more problems)
posted by DreamerFi at 1:01 PM on April 1, 2009

« Older Insight, the big brother, or bigger brother?   |   Help. First-time dogparent needs housebreaking... Newer »
This thread is closed to new comments.