← Начало
Виж статията
Редакция: How do I test SMTP email sending with PHPMailer?
Заглавие
Slug
URL: https://team1.nqma.info/a/
how-do-i-test-smtp-email-sending-with-phpmailer
Категория
(без категория)
100WS Hosting Limitations
Account Access
Account Management
Account Usage
Application Installer
Backups
Control Panel
Cron Jobs
cURL
Database Configuration
Database Maintenance
Database Management
Databases
Dedicated IP
DNS
DNS Configuration
Domain Management
Domain Registration
Domain Transfers
Domain Validation
Email
Email (SMTP) Restrictions
Email Configuration
Email Management
Email Support
Email Troubleshooting
Free Hosting Limitations
FTP Configuration
Google Apps
Hosting Migration
Joomla
Legacy Tools
Logs
Mailing List
MySQL
Network
Network Troubleshooting
NodeJS
Performance
Prestashop
Pricing
Remote Server Connection Block
Reseller Configuration
Reseller Customization
Reseller Mode
Sales Verification
Scripting
Scripting Support
Security
Server Configuration
Server Issues
Server Management
SFTP
SSL
Storage
Support Tickets
Technical Support
Testing
Uncategorized
VPS
Website Configuration
Website Errors
Website Security
WooCommerce
WordPress
WordPress Management
Zen Cart
Пинната статия (винаги най-горе)
Съдържание
<p>To test SMTP email sending using PHPMailer, follow these steps over SSH:</p><ol><li><strong>Download PHPMailer:</strong><pre>wget https://github.com/PHPMailer/PHPMailer/archive/master.zip unzip master.zip mv PHPMailer-master PHPMailer</pre></li><li><strong>Create a <code>test.php</code> file</strong> in the same directory with the following code, updating the settings with your email credentials:</li></ol><pre><?php use PHPMailerPHPMailerPHPMailer; use PHPMailerPHPMailerSMTP; use PHPMailerPHPMailerException; require_once __DIR__ . '/PHPMailer/src/Exception.php'; require_once __DIR__ . '/PHPMailer/src/PHPMailer.php'; require_once __DIR__ . '/PHPMailer/src/SMTP.php'; $mail = new PHPMailer(true); try { $mail->SMTPDebug = SMTP::DEBUG_SERVER; $mail->isSMTP(); $mail->Host = 'mail.kiirahosting.com'; $mail->SMTPAuth = true; $mail->SMTPSecure = "ssl"; $mail->Port = 465; $mail->Username = 'websitetest@nilevillagehotel.com'; $mail->Password = 'Muw0gg0@2021'; $mail->setFrom('websitetest@nilevillagehotel.com', 'Sender Name'); $mail->addAddress('nilevillagehotelspa@gmail.com', 'Receiver Name'); $mail->addReplyTo('websitetest@nilevillagehotel.com', 'Sender Name'); $mail->IsHTML(true); $mail->Subject = "Test Email via SMTP and PHPMailer"; $mail->Body = 'This is an <b>HTML</b> test email.'; $mail->AltBody = 'Plain text test email for non-HTML clients.'; $mail->send(); echo "Email sent successfully."; } catch (Exception $e) { echo "Email sending failed. Error: {$mail->ErrorInfo}"; } ?></pre><p>Run the script to test. Ensure your credentials and server settings are correct.</p>
Запази
Преглед