KnowledgebaseHow can we help you?

Email Sending through Code in PHP

Download Zip File.

In Zip File there are 4 files, 3 php and 1 Txt file(Txt file content Given Below).

Code Given In .txt file is to be used in your mail sending form(php or Html).
3 PHP files needs to be kept along with mail sending form(Php or Html).

Code needs to be adjusted, according to your need in Php or Html form.


include 'class.smtp.php';
require_once('class.phpmailer.php');
$mail = new PHPMailer();
$config = array();
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'domain name hosted on our server';
$config['smtp_user'] = 'test@domain.com';
$config['smtp_pass'] = 'password';
$config['smtp_port'] = '25';
$mail->SetFrom('test@domain.com', 'username ');
$mail->Subject = $subject;

$mail->MsgHTML($message);


$mail->AddAddress("test@domain.com");
if ($mail->Send()) {
    echo "sent";
} else {
    echo "Mailer Error: " . $mail->ErrorInfo;
}

Was this answer helpful?

Also Read

Gen X Web Hosting
Have a question? Call us.
+91 94296 92542
10:00 am – 7:30 pm IST, Mon–Sat
Live chat, email & tickets 24/7
Hosting
Linux Shared Windows Shared Reseller Hosting Node X Virtual Cloud Dedicated Servers
Products
Register Domains Transfer Domains SSL Certificates n8n Hosting Business Email
Company
About Us Contact Us Blog Careers Affiliates
Support
Open Ticket Knowledgebase Support Center
HostAdvice Great Uptime Award for Gen X Web Hosting Gen X Web Hosting Reviews Gen X Web Hosting Reviews
Copyright © 2026 Gen X Web Hosting. All rights reserved.
Privacy Policy Terms of Use Site Map