Hello. I wrote a script in PHP to send e-mails but I get error Failed to connect to smtp.eunet.rs:25 [SMTP: Failed to connect socket: Permission denied (code: -1, response: )]. I have Fedora 12 on my computer. Can anyone help with this? Thanks.
PHP script code:
<?php
include('Mail.php');
ini_set('display_errors',1);
error_reporting(E_ALL|E_STRICT);
$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"]="somepass";
//$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 form that goes with the script
<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>
PEAR mail failed to connect socket error
Started by 123np, Jun 17 2010 02:14 AM
1 reply to this topic
#1
Posted 17 June 2010 - 02:14 AM
|
|
|
#2
Posted 17 June 2010 - 05:43 AM
The error code -1 can mean any number of things. The first thing I can spot is the following code:
There's a unary negative there, which negates the name to be within RFC compliant specification, although I'm not sure what it'd do to it. Try fixing that and seeing if it runs, it should be valid code you have.
$name=-$_POST['name'];
There's a unary negative there, which negates the name to be within RFC compliant specification, although I'm not sure what it'd do to it. Try fixing that and seeing if it runs, it should be valid code you have.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.


Sign In
Create Account

Back to top









