Documentation Index
Fetch the complete documentation index at: https://help.onetsolutions.net/llms.txt
Use this file to discover all available pages before exploring further.
To ensure email deliverability and security, we recommend using SMTP authentication instead of the PHP mail() function.
The PHP mail() function is disabled on our servers due to security concerns. It lacks authentication and is commonly exploited by malicious scripts.
Using PHPMailer with SMTP
Prerequisites
- A Web Hosting service with OnetSolutions
- An email account created in cPanel
- PHPMailer library installed in your project
Installation
Download PHPMailer from the official GitHub repository or install via Composer:
composer require phpmailer/phpmailer
SMTP Configuration
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'vendor/autoload.php';
$mail = new PHPMailer(true);
try {
// SMTP settings
$mail->isSMTP();
$mail->Host = 'mail.yourdomain.com';
$mail->SMTPAuth = true;
$mail->Username = 'your-email@yourdomain.com';
$mail->Password = 'your-email-password';
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
$mail->Port = 587;
// Email content
$mail->setFrom('your-email@yourdomain.com', 'Your Name');
$mail->addAddress('recipient@example.com', 'Recipient Name');
$mail->Subject = 'Subject of your email';
$mail->Body = 'Content of your email';
$mail->send();
echo 'Email sent successfully!';
} catch (Exception $e) {
echo "Error: {$mail->ErrorInfo}";
}
SMTP Settings
Use these settings to configure your PHP application for sending emails.
| Setting | Value |
|---|
| Host | mail.yourdomain.com |
| Port | 587 (TLS) or 465 (SSL) |
| Encryption | STARTTLS or SSL |
| Username | Your full email address |
| Password | Your email password |
Security Best Practice: Never hardcode your email credentials directly in your code. Use environment variables or a configuration file outside your web root to store sensitive information.
Test your email configuration by sending a test message to yourself before deploying to production.