Jump to content

SMTP Error: Could not connect to SMTP host


extinct222

Recommended Posts

I am very new to everything I was wondering if someone can check this and tell me what I might of done wrong and how to fix the error

Mailer Error: SMTP Error: Could not connect to SMTP host.  In my error logs I was getting errors on line 70 regarding the $from being undefined any help would be greatly appreciated thank you

 

<?php



if(isset($_POST["Submit"]))

{

require("c:\phpmailer\class.phpmailer.php");
require("c:\phpmailer\class.smtp.php");




$mail = new PHPMailer();


////////////////////////////////////////////////////////////////

// Customize the following 5 lines with your own information. //

////////////////////////////////////////////////////////////////



$toaddress = "mydomainnameemailwashere@gmail.ca";  //Change this to the email address you will be receiving your notices.

$mailhost = "ssl://smtp.gmail.com";  //Change this to your actual Domain name.

$mail->Port = 465;

$mail->SMTPAuth = true; // turn on SMTP authentication 

$mail->Username = "mygmailemailwashere@gmail.ca"; // SMTP username 

$mail->Password = "mypasswordwashere"; // SMTP password   //Change this to the above email addresses password.

$subject = "PHP Contact Form";  //Change this to your own email message subject.



//////////////////////////////////////////

// DO NOT CHANGE ANYTHING PAST THIS LINE//

//////////////////////////////////////////



$fromname = $_POST["TName"];

$body = $_POST["TBody"] ;

$rplyto = $_POST["TEmail"];

$msgbody = $fromname . "<br>" . $rplyto . "<br>" . $body;



$mail->IsSMTP();

$mail->Host = $mailhost;

$mail->SMTPAuth = true;

$mail->Username = $fromaddress;

$mail->Password = $frompwd;

$mail->From = $fromaddress;

$mail->FromName = $fromname;

$mail->AddReplyTo($rplyto);

$mail->AddAddress($toaddress);

$mail->IsHTML(true);

$mail->Subject = $subject;

$mail->Body = $msgbody;



if(!$mail->Send())

{

   echo "Message could not be sent. <p>";

   echo "Mailer Error: " . $mail->ErrorInfo;

   exit;

}



echo "Thank you, your message has been sent!";

}



?>



<html><body>

<form name="SendEmail01" method="post">

<table border=0>

<tr>

        <td>Name:</td>

        <td><input type="text" name="TName" size="30"></td>

</tr>

<tr>

        <td>Email:</td>

        <td><input type="text" name="TEmail" size="30"></td>

</tr>

<tr>

        <td>Body:</td>

        <td><textarea rows="4" name="TBody" cols="30"></textarea></td>

</tr>

<tr>

        <td><input type="submit" name="Submit" value="Submit"></td>

</tr>

</table>

</form>

</body></html>

 

MOD EDIT:

 . . . 

BBCode tags added.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.