Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP Mailer works on localhost (MAMP), but not on live site
    text
    copied!<p>I'm learning to make websites and I'm putting together a simple website for my parents business. I made a contact form and the message is just emailed to my parents' email. I just looked up a sample GMail PHP code to send mail and it works when I test it with MAMP, but when I upload it to the live site, I get this error:</p> <blockquote> <p>SMTP Error: Could not connect to SMTP host. Mailer Error: SMTP Error: Could not connect to SMTP host.</p> </blockquote> <p>Why doesn't it work on the live site, but it works when I test it on MAMP? Here's my code:</p> <pre><code>require("phpmailer/class.phpmailer.php"); $mail = new PHPMailer(); $mail-&gt;IsSMTP(); // send via SMTP $mail-&gt;Host = "myparentswebsite.com"; $mail-&gt;Mailer = "smtp"; $mail-&gt;Host = "ssl://smtp.gmail.com"; $mail-&gt;Port = 465; $mail-&gt;SMTPAuth = true; // turn on SMTP authentication $mail-&gt;Username = "parentswebsite@gmail.com"; // SMTP username $mail-&gt;Password = "paswsword"; // SMTP password $webmaster_email = "parentswebsite@gmail.com"; //Reply to this email ID $email= $_POST['email']; // Recipients email ID $name= $_POST['name']; // Recipient's name $mail-&gt;From = $webmaster_email; $mail-&gt;FromName = "parentswebsite"; $mail-&gt;AddAddress($email,$name); $mail-&gt;AddReplyTo($webmaster_email,"Webmaster"); $mail-&gt;WordWrap = 50; // set word wrap $mail-&gt;IsHTML(true); // send as HTML $mail-&gt;Subject = "Feedback from parentswebsite.com"; $mail-&gt;Body = $_POST['name']. " " .$_POST['email']. " ". $_POST['phone']. " ". $_POST['message'] ;//HTML Body echo "it works"; $mail-&gt;AltBody = "This is the body when user views in plain text format"; //Text Body if(!$mail-&gt;Send()) { echo "Mailer Error: " . $mail-&gt;ErrorInfo; } else { echo "We have received your message!"; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload