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



+91 9569505379 (Till Covid -19 Outbreak)
10:00 am to 7:30 pm IST Monday to Saturday
Live Chat, Email and Tickets are available 24/7

HostAdvice Great Uptime Award for Gen X Web Hosting
Gen X Web Hosting Reviews