FormMaillyGo - Documentation
FormMaillyGo is your serverless contact-form backend. It transforms any static website form into a professionally formatted HTML email, delivered securely via SMTP. Deploy on AWS Lambda for 1M free requests/month, no monthly fees, and full control over your data.
Leverage Gmail’s proven SMTP infrastructure, and eliminate vendor lock-in. Perfect for solo developers, indie hackers, and startups.
1. Prerequisites
- An AWS account.
- Go ≥1.24 installed (golang.org/dl/).
- A Gmail account with 2FA enabled.
- Download the project (FormMaillyGo.zip).
2. Enable Gmail 2FA & Create App Password
- Go to Google Account → Security.
- Under “Signing in to Google,” enable 2-Step Verification.
- Now search App passwords from the search bar. (Or click google.com/apppasswords.)
- Name it “FormMaillyGo”, then click Create.
- Copy the 16-character password (no spaces) and store it securely. You’ll set it as
SENDER_EMAIL_PASSWORD
in Lambda.
Note: Treat this app password like your main password—do not share it.
3. Build & Package Your Go Lambda
Open your project folder in terminal, compile your Go handler for AWS Lambda’s Linux/ARM64 environment and package it with your frontend:
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 \
go build -tags=lambda.norpc -o bootstrap cmd/form_mailly_go/serverless/aws_lambda.go
zip -r lambda-handler.zip bootstrap public/
lambda-handler.zip
→ file will be generated, now upload that file to AWS Lambda.
4. AWS Account Setup
- Visit aws.amazon.com and click create account.
- Enter email, password, and billing details.
5. Create & Configure Lambda Function
- In AWS Console, search Lambda then click on Create function.
- Author from scratch:
- Function name:
FormMaillyGo
- Runtime:
Amazon Linux 2023
- Architecture:
arm64
- Function name:
- Click Create function.
- Under Code → Upload from → .zip file, upload
lambda-handler.zip
and click Save. - Still in Code, edit Runtime settings → set Handler to
main
and Save.
6. Configure Environment Variables
Keep secrets out of code—use Lambda environment variables instead.
SENDER_EMAIL
: your Gmail address (e.g.,you@gmail.com
)SENDER_EMAIL_PASSWORD
: the 16-char App Password you generatedRECEIVER_EMAIL
: where messages will be sentSMTP_HOST
:smtp.gmail.com
SMTP_PORT
:587
Navigate to Configuration → Environment variables → Edit → Add environment variable, add each key/value pair, then Save.
7. Expose Your Function via HTTP
7.1 Create a Lambda Function URL
- Same Configuration page, go to Function URL.
- Click Create function URL.
- Auth type: NONE (public). Click Save.
- Copy the Function URL (e.g.,
https://abcd.lambda-url.us-east-1.on.aws/
).
This URL directly invokes your Lambda—no API Gateway needed.
- Same Configuration page, go to General configuration → Edit.
- Set Timeout → 10sec or more (as per need) → save
8. Test Your Deployment
Open terminal and copy-paste this command, make sure to update the function url.
curl -X POST https:// --YOUR-FUNCTION-URL-- /api/contact \
-H "Content-Type: application/json" \
-d '{
"name": "Alice",
"email": "alice@email.com",
"subject": "Product Feedback",
"message": "Loved your product!",
"product_name": "FormMaillyGo",
"product_website": "https://ajaynegi45.github.io/FormMaillyGo"
}'
{ "message": "Email sent successfully" }
If you get this response and an email in your RECEIVER_EMAIL
inbox. 🎉
9. Troubleshooting & Tips
- Logs & monitoring: Click Monitor → View CloudWatch logs → Search log group.
- Timeouts: Increase Lambda timeout under Configuration → General configuration.