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.

<?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 25 Nov '10, 07:03

lamusoftware's gravatar image

lamusoftware
18712
accept rate: 16%

1

PEAR is definitely installed (as you noticed, require_once doesn'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.

(25 Nov '10, 07:07) David L ♦♦ David%20L's gravatar image
Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×185
×52
×8

Asked: 25 Nov '10, 07:03

Seen: 1,217 times

Last updated: 25 Nov '10, 07:07

Plans & prices    Sign up    Why WebFaction?    Contact us    Affiliate program    Support    Legal    Jobs    Blog    Control panel login
Powered by OSQA
© Copyright 2003-2012 Swarma Limited - WebFaction is a service of Swarma Limited