Jump to content

Help with PEAR mail

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
123np

123np

    Newbie

  • Members
  • Pip
  • 7 posts
Hello. I wrote a simple PHP script (found below) to process and e-mail a form. From it I get error Failed to connect to p:p [SMTP: Failed to connect socket: fsockopen() expects parameter 5 to be double, string given (code: -1, response: )]. Can anyone help with this?

PHP script code is:

<?php
include('Mail.php');

$name=-$_POST['name'];
$email=$_POST['email'];
$feedback=$_POST['comments'];
$toaddress='nikola_pav@eunet.rs';
$mailcontent="Customer name: ".$name."\n".
"Customer email: ".$email."\n".
"Customer comments: \n".$feedback."\n";

$headers["From"]="nikola_pav@eunet.rs";
$headers["To"]="nikola_pav@eunet.rs";
$headers["Subject"]="Comments";

$params["host"]="smtp.eunet.rs";
//$params["port"]=25;
$params["auth"]=true;
$params["username"]="nikola_pav";
$params["password"]="some_pass";
//$params["timeout"]=20;
//$params["debug"]=true;

$mail_object=&Mail::factory("smtp",params);

if(PEAR::isError($mail_object))
echo "Mail object error: ".$mail_object->getMessage()."<br/>";
else
echo "Mail object successfully created <br/>";

$res=$mail_object->send($toaddress,$headers,$mailcontent);

if (PEAR::isError($res)) {
echo("<p>" . $res->getMessage() . "</p>");
} else {
echo("<p>Message successfully sent!</p>");
}
?>
<html>
<head>
<title>Bob's auto parts-Feedback submitted</title>
</head>
<body>
<h1>Feedback submitted</h1>
<p>Your feedback has been sent</p>
</body>
</html>

HTML code for the form is:

<form action="komentari.php" method="post">
<table>
<tr><td><b><font size="4">Customer feedback</font></b></td></tr>
<tr><td></td></tr>
<tr><td></td></tr>
<tr><td>Please tell us what you think</td</tr>
<tr><td></td></tr>
<tr><td>Your name</td></tr>
<tr><td><input type="text" name="name" size="20"/></td></tr>
<tr><td></td></tr>
<tr><td>Your e-mail address</td></tr>
<tr><td><input type="text" name="email" size="20"/></td></tr>
<tr><td></td></tr>
<tr><td>Your feedback</td></tr>
<tr><td><textarea name="comments"></textarea></td></tr>
<tr><td></td></tr>
<tr><td><input type="submit" value="Submit form"/></td></tr>
</table>
</form>

Thanks.

#2
123np

123np

    Newbie

  • Members
  • Pip
  • 7 posts
I also want to add that I'm using Fedora 12 on my computer.