I know very little about PHP but need to move a PHP site temporarily to Webfaction before rewriting it to Django.
I tried to rewrite the below PHP file to use PEAR but I get no error message and don't receive any email.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33 | <?php
require_once "Mail.php";
if(!empty($HTTP_POST_VARS['sender_mail']))
{
$from_addr = "existing.address@webfaction-address.com";
$to = "my@email.com";
$subject = "Test";
$body = stripslashes($HTTP_POST_VARS['sender_name'])."\n".stripslashes($HTTP_POST_VARS['sender_email'])."\n".stripslashes($HTTP_POST_VARS['sender_phone'])."\n".stripslashes($HTTP_POST_VARS['sender_postal'])."\n".stripslashes($HTTP_POST_VARS['sender_code'])."\n".stripslashes($HTTP_POST_VARS['sender_city'])."\n".stripslashes($HTTP_POST_VARS['sender_country']);
$body .= "\n\n---------------------------\n";
$body .= "Mail sent by: " . $HTTP_POST_VARS['sender_name'] . " <" . $HTTP_POST_VARS['sender_mail'] . ">\n";
$headers = array ("From" => $from_addr,
"To" => $to,
"Subject" => $subject
"Reply-To => "Reply-To: " . $HTTP_POST_VARS['sender_name'] . " <" . $HTTP_POST_VARS['sender_mail'] . ">");
$smtp = Mail::factory("smtp", array ('host' => "smtp.webfaction.com",
'auth' => true,
'username' => "xxxxxxxxxxx",
'password' => "xxxxxxxxxxx"));
$mail = $smtp->send($to, $headers, $body);
if ( PEAR::isError($mail) ) {
echo $mail->getMessage();
}
else {
echo "output=sent";
}
} else {
echo "output=error&info=no-email";
}
?>
|
Result is always output=sent but email is never received. I am using a Static/ CGI/ PHP app. Do I need to install the PEAR mail package? Does not seem like it as require_once "Mail.php"; does not give any error message.
Any easy way to debug?
asked
Nov 25 '10 at 07:03
lamusoftware
167●9
PEAR is definitely installed (as you noticed,
require_oncedoesn't fail). Could you give us the to/from addresses? We'll check our mail logs and see if anything turns up.If you'd rather not give that information out here, you can open a support ticket.