1

I have an HTML form for a website hosted on GoDaddy, I'm trying to allow users to use a contact form to contact me via my website, I've created an smtp PHP script however it doesn't seem to work, the script runs and the page reloads but I haven't received any income mail for this test.

<?php

include('Mail.php');

$host = 'localhost'; 

$username = '******@***********.com';
$password = '*******';
$subject = 'Test';
$from = '******@*********.com'; 
$to = '******.*******@***.com';
$cc = 'person to CC';

$recipients = $to . ", " . $cc; // 

$headers = array ('From' => $from,
'To' => $to,
'Cc' => $cc,
'Subject' => $subject); 

$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => false,
'username' => $username,
'password' => $password,
'port' => '25'
)); 

$mail = $smtp->send($recipients, $headers, $body); 


if ( PEAR::isError($mail) ) {
    echo("<p>Error sending mail:<br/>" . $mail->getMessage() . "</p>");
} else {
    echo("<p>Message sent.</p>");
} 

header("Location:contact-us.html");

?> 

  • Which message do you get? The error or the "sent" message? Remove the location header to find out. Also `var_dump($mail)` in the error case. – cweiske Nov 03 '21 at 10:41

0 Answers0