Note that there are some explanatory texts on larger screens.

plurals
  1. POSetting up phpmailer on iis7
    primarykey
    data
    text
    <p>I recently moved from windows shared hosting to a VPS. I'm struggling to get phpmailer to work for a contact form on my website.</p> <p>The code for my site the sets up the email to send is:</p> <pre><code>$mail-&gt;IsSMTP(); // set mailer to use SMTP $mail-&gt;Host = "smtp.gmail.com"; // specify main and backup server or localhost $mail-&gt;SMTPAuth = true; // turn on SMTP authentication $mail-&gt;SMTPSecure = "tls"; $mail-&gt;SMTPDebug = 1; // can vary the amount of debug info given on error $mail-&gt;Username = "mail@mydomain.com"; // SMTP username $mail-&gt;Password = "########"; // SMTP password $mail-&gt;Port = 587; </code></pre> <p>This code worked on the old windows shared hosting. Also everything else is identical too with the site (the class.phpmailer.php file etc)</p> <p>So I'm guessing it's something to do with my setup of iis or the server itself.</p> <p>Connecting out works on port 587 according to my webhosts who checked that for me</p> <p>I installed php using the Microsoft tool that does everything for you. the site is in php and is working, and it looks to my untrained eye like all is fine there.</p> <p>I've checked that php_openssl.dll is enabled.</p> <p>I've spent a long time reading around and fiddling with no luck. I'm really at a loss as what to look at next. Any ideas what it could be or what I should try?</p> <p>thanks!</p> <p>Phil. </p> <p>EDIT:</p> <p>The action on the php form is to go to contactprocessor.php. </p> <p>That file contains this code:</p> <pre><code>&lt;? ob_start(); if(isset($_POST['btnSubmit'])) { require("class.phpmailer.php"); $mail = new PHPMailer(); //Your SMTP servers details $mail-&gt;IsSMTP(); // set mailer to use SMTP $mail-&gt;Host = "smtp.gmail.com"; // specify main and backup server or localhost $mail-&gt;SMTPAuth = true; // turn on SMTP authentication $mail-&gt;SMTPSecure = "tls"; $mail-&gt;SMTPDebug = 1; // can vary the amount of debug info given on error $mail-&gt;Username = "mail@mydomain.com"; // SMTP username $mail-&gt;Password = "########"; // SMTP password $mail-&gt;Port = 587; $redirect_url = "http://www.mydomain.com/contact/contact_success.php"; //Redirect URL after submit the form $mail-&gt;From = $mail-&gt;Username; //Default From email same as smtp user $mail-&gt;FromName = "Website Contact Form"; $mail-&gt;AddAddress("mail@mydomain.com", "From Contact Form"); //Email address where you wish to receive/collect those emails. $mail-&gt;WordWrap = 50; // set word wrap to 50 characters $mail-&gt;IsHTML(true); // set email format to HTML $mail-&gt;Subject = "From Contact Form"; $message = "FullName: ".htmlspecialchars($_POST['fullname'])." &lt;br&gt; &lt;br&gt; \r\n &lt;br&gt;EmailAddress: ".htmlspecialchars($_POST['email'])." &lt;br&gt; &lt;br&gt; \r\n &lt;br&gt;Phone Number: ".htmlspecialchars($_POST['mobile'])." &lt;br&gt; &lt;br&gt; \r\n &lt;br&gt; Message: &lt;br&gt;".htmlspecialchars($_POST['message']); $mail-&gt;Body = $message; if(!$mail-&gt;Send()) { echo "Sorry the message could not be sent. Please email mail@mydomain.com instead. Thanks&lt;p&gt;"; echo "Mailer Error: " . $mail-&gt;ErrorInfo; exit; } echo "Message has been sent"; header("Location: $redirect_url"); } ?&gt; </code></pre> <p>Instead of actually sending the email, it just seems to print the above to screen of the user as if it's a webpage. it's as if the server thinks it's a html page and is just serving it.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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