Mohd Imran
Mohd Imran

Reputation: 3

PHPMailer on Godaddy server

Below is my code it works fine on XAMPP Server. When I load same to the Godaddy server it gives an error Class 'PHPMailer' not found in

I have loaded all PHPmailer files on godaddy server.

<?php
$email_from = "[email protected]";
$from = "Name";

include_once('PHPMailer/PHPMailerAutoload.php');
$mail = new PHPMailer(true);

//Send mail using gmail

$mail->IsSMTP(); // telling the class to use SMTP
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = 'ssl'; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port for the GMAIL server
$mail->Username = "[email protected]"; // GMAIL username
$mail->Password = "password"; // GMAIL password
$mail->IsHTML(true);

//Typical mail data
$mail->AddAddress($email, $name);
$mail->SetFrom($email_from, $from);
?>

Upvotes: 0

Views: 660

Answers (2)

Zzaly Oreo
Zzaly Oreo

Reputation: 31

Your email must be send through godaddy servers, and also disable all security features, username, and password:

$mail->isSMTP();
$mail->Host = 'relay-hosting.secureserver.net';
$mail->Port = 25;
$mail->SMTPAuth = false;
$mail->SMTPSecure = false;

You should view the PPMailer Troubleshooting https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting#godaddy

Upvotes: 0

Bing
Bing

Reputation: 3171

Your error message is coming from this line not finding/importing the PHPMailer class file:

include_once('PHPMailer/PHPMailerAutoload.php');

This definitely sounds like a pathing issue.

Are your directory paths all correct? That is, this PHP code -- is it running from a directory with PHPMailer directory in the same location? And if you're manually putting the files on your server, is your PHPMailerAutoload.php finding the PHPMailer class itself?

Upvotes: 1

Related Questions