Sending simple email from static page - docpad

I'm new to DocPad. I really like the idea of static page generation and had this in mind for some time, but great that there's already a mature project out there!
However, while I get a rough picture of how DocPad works, what would you recommend be the best way of creating a simple Contact Me page, that would email the input text to a specific address?
There is still requirement for server side code for this. How I see doing it right now, is having a html form doing a POST to nodejs server that will handle sending the email.
Is that a correct DocPad way of doing it, or I'm missing something?

Check out the contactform plugin :)

Related

Email Template URL - HTTPS issue

One of the client has asked the below, in reference to an old Email template we had created for them that they want to use.
We have an important email we need to send out to do with Apple Pay
and we have to use this link - shoebox://payment_setup.
The issue we have is where the template you guys built forces Https to
be added before every link it stops this link working. Are you able to
tell me which bit of code I would remove to stop this happening for
this email please? I am not editing the template as this is a one off
email we will just edit the individual email.
Please can you let me know solution to an issue like this?
Thanks
-Anjali

Implementing recaptcha on Github pages without php?

Absolute newb here, please forgive me for this basic question.
I have built my portfolio site using Github pages, but am experiencing spam via my contact form (hosted by GetSimpleForm). I am trying to implement Google reCAPTCHA, but I'm a bit stuck in the backend part. As I understand, Github pages don't support PHP, so I can not actually complete the form verification.
Google documentation here was unfortunately a bit overwhelming and cryptic to me as a beginner, since I just stared at my Github html/css/js files and had no clue what to put where.
Am I trying to do the impossible? Is it possible to use reCaptcha on Github pages? If so, is there a beginner friendly tutorial somewhere or a straightforward "copy-paste" thing I could use? (so far, it's not been clear where to use the secret key from the API key pair for example)
Thanks a bunch for any leads or alternative solutions for spam prevention that would work in Github pages!
The short answer is you cannot. Github Pages only support static site. You have to host your own website if you want to do some complex stuffs like backend check etc. and mostly they are not free.
The only suggestion I can come up is simply change your contact form to regular html form instead of hosting by the 3rd party website you are using. I suspect that the main reason you got spam is because you are using it's service.
A really simple way to do it is to make the form with HTML (you can either copy the code from a pre-made HTML site with a form, or find a youtube tutorial that shows you how to make a HTML form, pretty simple), and host it on something like Netlify. Netlify is free for static websites unless you are doing something really complicated, and it has a built in form submission that will send you an email automatically every time someone fills out the form. You don't need PHP or a third party app or anything.
You still create and edit the code of the website through Github, you just need to connect it to Netlify for the forms. I'm a complete beginner and I figured it out. Netfly has some tutorials that explain it nice and simple. No reason to pay or do a lot of complicated stuff, and you can make professional websites with just HTML and CSS.

Elegant/efficient means of sending email with Codeigniter and Sendgrid

I'm setting up some transactional email fun in our Codeigniter app via integrating with Sendgrid.
I've got things setup and ready to move forward with creating all of the specific transactions/emails, but I was wondering about the most efficient and/or elegant way of doing so.
It seems a bit convoluted to include the appropriate email code in each of the functions. To call a specific function from a clean and separated email controller would require me to use AJAX (so as to not cause a redirect).
Is there some way that I'm not considering currently that would help balance things, namely cleanliness and separation along with coherency and ease?
Thanks for any thoughts-
Not sure about the specifics of your application structure. But you could always create a model function and call that from the functions in your controller.
CodeIgniter also comes with some built in functionality to help you send emails, specifically setting some of your email settings in a config file so you don't have to rewrite that. http://ellislab.com/codeigniter/user-guide/libraries/email.html
I actually wrote a blog post about this not too terribly long ago. Have a look at this:
http://blog.sendgrid.com/using-sendgrid-with-php-codeigniter/
Essentially, codeigniter comes with an awesome email library that makes it easy to send stuff over SMTP, so I just show you how to hook into that.

How do I send an email from my webpage?

I am not a web developer but I do have a lot of programming experience in C# and Windows forms programming. On our company webpage my boss wants me to put in a textbox where visitors can submit a comment and press a submit button and that comment will be sent to an email address. Right now, our website uses just plain old html, no php or javascript or anything like that. I am wondering what is the simplest way to accomplish what I need? Can someone point me in the right direction? The website is hosted on an Apache server so I won't be able to use aspx.
The simplest method depends heavily on what is available. If PHP is supported, use it.
Here's a simple example (I wouldn't focus too much on their HTML -- which is a bit shoddy) but the PHP at the bottom to give you an idea on how to pull the <form> in and send the email.
If you don't have PHP and don't want to install it, you can do this without any server-side code and outsource the problem. Bravenet (a name that will be familiar with any old-school webdeveloper) have a free hosted form solution that lets you post your forms to their server and they email you the result.
Not amazingly professional, but takes about 10 seconds to implement.
The simplest solution would be have the form action as "mailto:email#address.com"
However, this has the downside of the email address being sent to being exposed to spam bots, along with the clients mail application having to load to send the email which can be confusing and slow.
Sending emails in PHP is common, and there are thousands of articles out there on how to do it, here's one
In this case the most simple way is to install PHP to your apache to use the mail()-function.
Of couse you could use tomcat additional to apache, but the configuaration is much more time-eating.
If you don't want to use any sort of scripting technology, then the form mailto might be your only option. You can just make the action of your HTML form mailto:youraddress and the form post will be mailed directly.
I would highly recommend looking into some sort of scripting technology though to do this in a more reliable way....PHP looks like a good fit in your environment.

how to upload a file with ajax,like what gmail does?

I know how to POST/GET text values with ajax,
but never know how to upload files with ajax.
Can someone just give a simple demo here?
GMail is actually using Flash for uploading files now... You could try looking into something like SWFUpload.
Ajax could certainly upload files by posting a HTML form with a input type="file" in it.
Some links to get you started:
http://www.webtoolkit.info/ajax-file-upload.html
http://www.ajaxf1.com/tutorial/ajax-file-upload-tutorial.html
Depending on the server/server side language you could probably send some kind of progress info to the client to render as a progress bar.
Check out this Ajax upload scripts, it has examples in Php and .Net. The basic idea behind the script is that you have to create an iFrame to handle this.
The YUI uploader is a flash based uploader that is designed to be very easy to integrate into javascript, with minimal knowledge of flash.
If you want a progress bar, I believe a pure javascript solution would require a server side piece to send back the current completion percentage via ajax, which would add quite a bit of complexity compared to a flash solution.

Resources