Hello Forum,
A little while ago, I posted an issue I was having with a PHP contact form that was sending fine, but my client wasn't receiving the form submissions. The entire thread is here. Eventually, I got it resolved with the forum's help when I was able to direct my VPS tech support folks to update the include_path in the server's php.ini file.
Now, I'm working on a new client site, trying to have an HTML form send its content via email using PEAR again. I copied the php script, updated the variables as necessary (username, password, host, etc.), but when I try to submit the form online, I get the following error:
authentication failure [SMTP: Invalid response code received from server (code: 535, response: 5.7.8 Error: authentication failed: authentication failure)]
I have tried to add the SMTP port (465) to my php code, but then I get a different error stating it can't connect.
Here's something that might be the problem, but I'm not sure. The current domain is hosted somewhere else. I'm redesigning their site, and uploading the files to its new account on my VPS. The DNS still points to the current site, and only when this new site is ready, I will update the nameservers at the host to point to my nameservers. Could the script be having trouble connecting to my server (where I'm testing the form), because the mail.example.com server is the current host?
Here's the PHP script (perhaps there's an issue here that I can't see):
<?php
require_once 'Mail.php';
$from = "mail@newdomain.com";
$to = "info@newdomain.org";
$subject = "Application Form";
$name = Trim(stripslashes($_POST['Name']));
$birthday = Trim(stripslashes($_POST['Birthday']));
$email = Trim(stripslashes($_POST['Email']));
$replyTo = $email;
// smtp requirements
$host = "mail.newdomain.com";
$username = "username";
$password = "password";
// prepare email body text
$body = "";
$body .= "Name: ";
$body .= $name;
$body .= "\n";
$body .= "Birthday: ";
$body .= $birthday;
$body .= "\n";
$body .= "Email: ";
$body .= $email;
$body .= "\n";
$headers = array ('From' => $from,
'To' => $to,
'Reply-To' => $replyTo,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
print "<meta http-equiv=\"refresh\" content=\"0;URL=applicationthanks.html\">";
}
?>
Thanks for your time and any hints!
Mindy : )