A lightweight, ready-to-integrate PHP email kit built on top of PHPMailer. Includes a Contact Us page and a Subscribe / Newsletter page — both fully functional, responsive, and easy to customize.
No database required. Just PHP, Composer, and an SMTP account.
- Single config file — edit
config.phponce, everything works - Contact Us page — sends message to admin + auto-reply to visitor
- Subscribe page — welcome email to subscriber + admin notification
- Input sanitization — XSS-safe, validated before sending
- Responsive design — works on desktop, tablet, and mobile
- Lightweight — no heavy JS frameworks, no glowing effects, fast loading
- Easy theming — change one CSS variable to rebrand
- Bootstrap Icons — consistent icon set via CDN
| File | URL | Description |
|---|---|---|
index.php |
/ |
Landing page & documentation |
contact.php |
/contact.php |
Contact Us form |
subscribe.php |
/subscribe.php |
Newsletter subscribe form |
config.php |
— | SMTP configuration (edit this) |
style.css |
— | Shared stylesheet |
- PHP 7.4 or higher
- Composer
- An SMTP account (Gmail, Mailgun, Mailtrap, etc.)
git clone https://github.com/cdn-lib/smtp.git
cd smtpcomposer require phpmailer/phpmailerOpen config.php and fill in your details:
define('SMTP_HOST', 'smtp.gmail.com');
define('SMTP_PORT', 465);
define('SMTP_USERNAME', 'your-email@gmail.com'); // Your SMTP email
define('SMTP_PASSWORD', 'your-app-password'); // App password
define('SMTP_FROM_NAME', 'Your Company Name');
define('SMTP_ENCRYPTION','ssl'); // 'ssl' or 'tls'
define('ADMIN_EMAIL', 'admin@yourcompany.com'); // Receives contact messages
define('SITE_NAME', 'Your Company');
define('SITE_URL', 'https://yourcompany.com');Gmail users: Enable 2-Step Verification and generate an App Password. Do NOT use your regular account password.
Upload all files to your web server. No database setup needed.
your-server/
├── vendor/ ← generated by Composer
├── config.php
├── contact.php
├── index.php
├── style.css
├── subscribe.php
└── composer.json
| Constant | Default | Description |
|---|---|---|
SMTP_HOST |
smtp.gmail.com |
SMTP server hostname |
SMTP_PORT |
465 |
465 for SSL, 587 for TLS |
SMTP_USERNAME |
— | SMTP login email |
SMTP_PASSWORD |
— | App password |
SMTP_FROM_NAME |
— | Sender display name |
SMTP_ENCRYPTION |
ssl |
ssl or tls |
ADMIN_EMAIL |
— | Inbox that receives contact messages |
SITE_NAME |
— | Used in email subjects and footers |
SITE_URL |
— | Your website URL |
All colors are defined as CSS variables at the top of style.css:
:root {
--accent: #4F46E5; /* Change this to rebrand */
--accent-hover: #4338CA;
--bg: #F3F4F6;
--bg-card: #FFFFFF;
/* ... more tokens */
}To switch to a dark theme, just override the root variables in a <style> block on the pages you need.
In subscribe.php, edit the $interest_options array:
$interest_options = [
'news' => ['label' => 'Latest News', 'desc' => 'Stay up to date'],
'products' => ['label' => 'New Products', 'desc' => 'First to know'],
// Add or remove entries as needed
];- All POST inputs are sanitized with
htmlspecialchars()andfilter_var() - SMTP credentials are stored in
config.php— make sure this file is not publicly accessible if using plain PHP hosting - For production, consider moving
config.phpabove the web root - Never commit real credentials — use environment variables or
.envfiles in production
| Provider | Host | Port | Encryption |
|---|---|---|---|
| Gmail | smtp.gmail.com |
465 | SSL |
| Outlook | smtp.office365.com |
587 | TLS |
| Mailgun | smtp.mailgun.org |
587 | TLS |
| Mailtrap (testing) | smtp.mailtrap.io |
2525 | TLS |
| SendGrid | smtp.sendgrid.net |
587 | TLS |
MIT License — free to use, modify, and distribute.
- PHPMailer — email sending library
- Bootstrap Icons — icon set
- Google Fonts — Inter — typography