Sending Email from Godaddy Servers Using PHP: In this tutorial, we will see how to send email using PHP from GoDaddy servers.
- Download PHPMailer here
- PHP script as below
<?php
require 'PHPMailer-master/PHPMailerAutoload.php';
$email='testemail@email.com';//change email to receipents email
$mail = new PHPMailer();
$mail->SMTPDebug = 0;
$mail->SMTPAuth = false;//SMTP authentication should be false
$mail->SMTPSecure = 'none';// Security type should be none
$mail->Host = 'localhost';// SMTP host name should be localhost
$mail->Port = 25;
$mail->setFrom('test@yourdomain.com', 'test email'); //Set who the message is to be sent from
$mail->addReplyTo('test@yourdomain.com', 'test email'); //Set an alternative reply-to address
$mail->addAddress($email); // Add a recipient
$mail->WordWrap = 50; // Set word wrap to 50 characters
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Test email';
$mail->Body = "Test Body";;
if(!$mail->send()) {
echo 'Mailer Error: ' . $mail->ErrorInfo;
echo 'Email Has not Sent';
exit;
}
else{
echo "email sent";
}
?>
- Go to your Cpanel and upload the file and try to execute the script from the browser and see your inbox for an email.
- before executing change the recipient’s email to the valid email address and valid from email.
Happy programming.
Also Read: Sending Email using PHPMailer
Sending Email from Godaddy Servers Using PHP
