Skip to content

vall-dev/smtp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP SMTP Mailer Kit

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.


Features

  • Single config file — edit config.php once, 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

Pages

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

Requirements

  • PHP 7.4 or higher
  • Composer
  • An SMTP account (Gmail, Mailgun, Mailtrap, etc.)

Installation

1. Clone the repository

git clone https://github.com/cdn-lib/smtp.git
cd smtp

2. Install dependencies

composer require phpmailer/phpmailer

3. Configure your SMTP credentials

Open 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.

4. Deploy

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

Configuration Reference

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

Theming / Customization

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.


Customizing Subscribe Interests

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
];

Security Notes

  • All POST inputs are sanitized with htmlspecialchars() and filter_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.php above the web root
  • Never commit real credentials — use environment variables or .env files in production

SMTP Providers

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

License

MIT License — free to use, modify, and distribute.


Credits

About

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.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors