gcf

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2022 License: MPL-2.0 Imports: 4 Imported by: 0

README

Getting Started with Google Cloud Functions

  1. Create a Google Cloud Function 2nd generation.
  2. Create a function.go in your project root:
package gcf

import (
	"net/http"
	"github.com/Rubonnek/formailer"
	"github.com/Rubonnek/formailer/handlers"

	"github.com/GoogleCloudPlatform/functions-framework-go/functions"
)

// Formailer handles all form submissions
func Formailer(w http.ResponseWriter, r *http.Request) {
	contact := formailer.New("Contact")
	contact.AddEmail(formailer.Email{
		ID:      "contact",
		To:      "info@domain.com",
		From:    `"Company" <noreply@domain.com>`,
		Subject: "New Contact Submission",
	})

	handlers.Vercel(formailer.DefaultConfig, w, r)
}

// Google Cloud Function entry point defined as "main":
func init() {
	functions.HTTP("main", Formailer)
}
  1. Add your SMTP settings in the Cloud Functions UI.

  2. Add a hidden input to your form.

<input type="hidden" name="_form_name" value="Contact">

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Formailer

func Formailer(w http.ResponseWriter, r *http.Request)

Formailer handles all form submissions

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL