Home »
Imported messages »
comp.lang.php »
Cannot send emails
Cannot send emails [message #173149] |
Thu, 24 March 2011 17:39 |
Marco
Messages: 11 Registered: March 2011
Karma:
|
Junior Member |
|
|
Hi,
I have problems sending mails. The messages are as follows:
PHP Warning: Connection refused in /usr/share/php/PEAR.php on line 873
PHP Warning: Failed to connect socket: Connection refused in /usr/share/php/PEAR.php on line 873
I used the following code:
<?php
require_once 'Mail.php';
require_once 'PEAR.php';
define('MYCLASS_ERROR_CODE', 1);
PEAR::setErrorHandling(PEAR_ERROR_TRIGGER, E_USER_WARNING);
$from_name = 'Marco';
$to_name = 'Recipient';
$subject = 'Testmail';
$mailmsg = 'dummy content';
$From = "From: ".$from_name." <myaddress(at)domain(dot)net>";
$To = "To: ".$to_name." <recipientaddress(at)domain(dot)net>";
$recipients = "recipientaddress(at)domain(dot)net";
$headers["From"] = $From;
$headers["To"] = $To;
$headers["Subject"] = $subject;
$headers["Reply-To"] = "myaddress(at)domain(dot)net";
$headers["Content-Type"] = "text/plain; charset=UTF-8";
$headers["Return-path"] = "myaddress(at)domain(dot)net";
$smtpinfo["host"] = "server.com";
$smtpinfo["port"] = "25";
$smtpinfo["auth"] = true;
$smtpinfo["username"] = "myusername";
$smtpinfo["password"] = "verysecret";
$mail_object =& Mail::factory("smtp", $smtpinfo);
$mail_object->send($recipients, $headers, $mailmsg);
?>
When I use the same host, port, username and password in my mail program I can
send mails. What is wrong with this setup?
Marco
|
|
|
Goto Forum:
Current Time: Mon Nov 25 22:59:24 GMT 2024
Total time taken to generate the page: 0.04529 seconds