/home/dvjjulio/fortexsecurity.com/README-EMAIL-SETUP.md
# Email Setup for Fortex Security Contact Form

This document explains how to set up the email functionality for the contact form on your Fortex Security website.

## Files Created/Modified

1. **`send-email.php`** - Main email processing script
2. **`config.php`** - Configuration file for email settings
3. **`index.html`** - Updated with form handling and JavaScript
4. **`README-EMAIL-SETUP.md`** - This setup guide

## Setup Instructions

### 1. Configure Email Settings

Edit the `config.php` file and update the following settings:

```php
// Change this to your actual email address
define('ADMIN_EMAIL', 'yourmail@gmail.com');

// Update company information if needed
define('COMPANY_NAME', 'Fortex Security');
define('COMPANY_ADDRESS', 'Circuito Federalistas 3586, Residencial Poniente');
define('COMPANY_CITY', 'Zapopan, Jalisco');
define('COMPANY_PHONE', '+52 33 1195 4663');
define('COMPANY_WEBSITE', 'www.fortexsecurity.com');
```

### 2. Server Requirements

Make sure your server has:
- PHP 7.0 or higher
- PHP mail() function enabled
- Session support enabled

### 3. Email Server Configuration

For the emails to work properly, you need to configure your server's email settings:

#### Option A: Using SMTP (Recommended)
If you want to use SMTP instead of the default mail() function, you can modify the `send-email.php` file to use PHPMailer or similar library.

#### Option B: Using Default mail() Function
The current implementation uses PHP's built-in mail() function. Make sure your hosting provider has email services configured.

### 4. Testing the Form

1. Upload all files to your web server
2. Open your website and go to the contact form
3. Fill out the form and submit
4. Check if you receive the email at the address specified in `ADMIN_EMAIL`

### 5. Troubleshooting

#### Emails not being sent:
1. Check if PHP mail() function is enabled on your server
2. Verify the email address in `config.php` is correct
3. Check your server's error logs
4. Enable debug mode by setting `DEBUG_MODE` to `true` in `config.php`

#### Form not working:
1. Make sure all files are uploaded to the same directory
2. Check browser console for JavaScript errors
3. Verify the form action points to the correct path

#### Spam issues:
1. Configure SPF, DKIM, and DMARC records for your domain
2. Use a proper "from" email address
3. Consider using a professional email service

## Features Included

- ✅ Form validation (client and server-side)
- ✅ AJAX form submission (no page reload)
- ✅ Loading states and user feedback
- ✅ Rate limiting (prevents spam)
- ✅ Input sanitization and security
- ✅ Automatic confirmation emails
- ✅ Responsive design
- ✅ Error handling and debugging

## Security Features

- Input sanitization to prevent XSS attacks
- Rate limiting to prevent spam
- Email validation
- CSRF protection (basic)
- Session-based request tracking

## Customization

### Changing Email Templates
You can modify the email content in `send-email.php` by editing the `$email_body` and `$user_body` variables.

### Adding CAPTCHA
To add CAPTCHA protection:
1. Set `ENABLE_CAPTCHA` to `true` in `config.php`
2. Add CAPTCHA implementation in the form
3. Add CAPTCHA validation in `send-email.php`

### Styling
The alert messages are styled with CSS. You can modify the styles in the `<style>` section of `index.html`.

## Support

If you encounter any issues:
1. Check the browser console for errors
2. Enable debug mode in `config.php`
3. Check your server's error logs
4. Verify all file permissions are correct

## File Permissions

Make sure the following files have proper permissions:
- `send-email.php` - 644
- `config.php` - 644
- `index.html` - 644

## Notes

- The form includes rate limiting (10 requests per hour per session)
- All emails include the sender's IP address for security
- The system sends both an admin notification and a user confirmation email
- Form validation includes minimum/maximum length requirements
- The system is designed to be spam-resistant and secure