Fork of https://github.com/rchakode/hugo-mx-gateway Contact form API for static websites
This repository has been archived on 2025-03-29. You can view files and clone it, but cannot push or open issues or pull requests.
Go to file
Rodrigue Chakode e7cac1bca9 updated config varible name
updated config varible name
2020-05-17 21:54:40 +02:00
.github/workflows updated CI workflow name 2020-05-17 20:07:40 +02:00
helm added helm deployment files 2020-05-17 19:09:32 +02:00
model improved sendmail + docs 2020-05-14 14:58:22 +02:00
templates renamed sample app config to app.yaml.sample 2020-05-12 23:41:17 +02:00
vendor core support for app engine 2020-05-10 01:20:35 +02:00
.dockerignore added dockerfile 2020-05-17 19:08:05 +02:00
.gcloudignore core support for app engine 2020-05-10 01:20:35 +02:00
.gitignore first commit 2020-05-10 00:02:18 +02:00
Dockerfile added dockerfile 2020-05-17 19:08:05 +02:00
LICENSE added LICENSE 2020-05-17 19:08:22 +02:00
Makefile restored deleted gcp deployment target 2020-05-17 21:53:35 +02:00
README.md improved sendmail + docs 2020-05-14 14:58:22 +02:00
app.yaml.sample updated config varible name 2020-05-17 21:54:40 +02:00
entrypoint.sh added missing docker entrypoint 2020-05-17 19:08:43 +02:00
go.mod core support for app engine 2020-05-10 01:20:35 +02:00
go.sum core support for app engine 2020-05-10 01:20:35 +02:00
main.go improved sendmail + docs 2020-05-14 14:58:22 +02:00
sendmail.go updated config varible name 2020-05-17 21:54:40 +02:00
swagger.yaml core support for app engine 2020-05-10 01:20:35 +02:00

README.md

Overview

Configuration variables

  • Create the App Engine configuration file
    cp app.yaml.sample app.yaml
    
  • Edit the app.yaml file with your favorite editor and set the following environement variables appropriately:
  SMTP_SERVER_ADDR: "smtp.mailgun.org:587"
  SMTP_VERITY_CERT: true
  SMTP_CLIENT_USERNAME: "postmaster@example.com"
  SMTP_CLIENT_PASSWORD: "postmasterSecretPassWord"
  CONTACT_REPLY_EMAIL: "noreply@example.com"
  CONTACT_REPLY_CC_EMAIL: "contact@example.com"
  DEMO_URL: "https://demo.example.com/"
  ALLOWED_ORIGIN_DOMAIN: "example.com"

Required HTTP Headers

  • Origin
  • Referer

SMTP

https://cloud.google.com/compute/docs/tutorials/sending-mail/using-mailgun?hl=fr

Test

curl -H'Origin: http://realopinsight.com'  \
    -H'Referer: realopinsight.com' \
    -H'Content-Type: application/x-www-form-urlencoded' \
    -d 'target=contact' \
    -XPOST https://hugo-mx-gateway.ew.r.appspot.com/sendmail 

Build

make build

Hugo Contact Form

See ./model/hugo-contact-form.html.

<div id="reply-message"></div>
<div>
   <fieldset>
      <legend>Please fill in the form to submit your request</legend>
      <form action="https://contact-request-endpoint/" method="post">
         <div class="form-item">
            <label for="name">Name</label>
            <input type="text" name="name" id="name"  placeholder="Mr. Smith" />
         </div>
         <div class="form-item">
            <label for="email">Email <span class="req"></span></label>
            <input type="text" name="email" id="email"  class="required email" placeholder="smith@company.com" />
         </div>
         <div class="form-item">
            <label for="organization">Organization</label>
            <input type="text" name="organization" id="organization"  placeholder="Company, Inc." />
         </div>
         {{ if in .Params.tags "contact" }}  
         <div class="form-item">
            <label for="subject">Subject</label>
            <input type="text" name="subject" id="subject"  value="" placeholder="Need help or expertise?" />
            <input type="hidden" name="target" id="target"  value="contact" />
         </div>
         <div class="form-item">
            <label for="message">Message</label>
            <textarea  rows="6" name="message" id="message"  placeholder="Please add details concerning your request."></textarea>
         </div>
         {{ else }}    
         <div class="form-item">
            <input type="hidden" name="subject" id="subject"  value="Your Access to Product Demo!" />
            <input type="hidden" name="target" id="target"  value="demo" />
         </div>
         {{ end }}
         <input  class="button"  type="submit" value="Submit">
      </form>
   </fieldset>
</div>