Cannot send emails

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

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:

  require_once 'Mail.php';
  require_once 'PEAR.php';

  define('MYCLASS_ERROR_CODE', 1);

  $from_name = 'Marco';
  $to_name   = 'Recipient';
  $subject   = 'Testmail';
  $mailmsg   = 'dummy content';

  $recipients              = "";
  $headers["From"]         = $From;
  $headers["To"]           = $To;
  $headers["Subject"]      = $subject;
  $headers["Reply-To"]     = "";
  $headers["Content-Type"] = "text/plain; charset=UTF-8";
  $headers["Return-path"]  = "";
  $smtpinfo["host"]     = "";
  $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?


Re: Cannot send emails

I tried
  telnet 25
and I got:
  telnet: Unable to connect to remote host: Connection refused

This should work, if I'm not mistaken, right? I have no clue, where the
problem could be. Why is the connection refused?


Re: Cannot send emails

Sorry for talking to myself. Here's the solution:

1) Try the correct port: 465
2) Use SSL: $smtpinfo["host"]     = "ssl://";
3) Happy Mailing :)

Thanks for listening.


Site Timeline