Issue with using corporate mail server smtp function

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
istvanb
Forum Newbie
Posts: 1
Joined: Tue Jul 06, 2010 7:15 am

Issue with using corporate mail server smtp function

Post by istvanb »

Hi,

I am having problems sending a mail by php using our corporate lotus mail server (please see the script below). By our IT department the lotus server on 192.168.20.99 requires NO authentication at all. When I run the script I get the following error message:

Failed to connect to 192.168.20.99:25 [SMTP: Failed to connect socket: No connection could be made because the target machine actively refused it. (code: -1, response: )]

I have no experience in php but the error message suggests me that my request is valid, but for some reasons the server rejects it. I have talked to the IT guys and we checked out the mail-server log which shows that there IS NO REQUEST arrived from my test-pc to the server. Which means it looks like the server does not rejects my request, it simply not even arrives!

To do my homework I installed outlook and created a new account which uses the IP and the Port number only. I was able to send messages to everywhere and the mail server log showed these messages without any problems.

So pretty much in outlook it works (outlook uses smtp as well to send out mails), but it does not work with php.

I am not sure if the script is correct since I just copied from the internet.

I use winXP with XAMPP (Apache and SQL running)

if you have any clue about what is wrong, please let me know, I need the solution desperatly!

thanks a lot,
istvan

Code: Select all

<?php
 require_once "Mail.php";

 $from = "istvanb@mycompany.com";
 $to = "istvanb@mycompany.com";
 $subject = "Hi!";
 $body = "Hi,\n\nHow are you?";

 $host = "192.168.20.99";
 $port = "25";
 $username = "";
 $password = "";

 $headers = array ('From' => $from,
  'To' => $to,
  'Subject' => $subject);
 $smtp = Mail::factory('smtp',
  array ('host' => $host,
    'port' => $port,
    'auth' => false,
    'username' => $username,
    'password' => $password));

 $mail = $smtp->send($to, $headers, $body);

 if (PEAR::isError($mail)) {
  echo("<p>" . $mail->getMessage() . "</p>");
 } else {
  echo("<p>Message successfully sent!</p>");
 }
 ?>
Last edited by Benjamin on Tue Jul 06, 2010 11:11 am, edited 1 time in total.
Reason: Added [syntax=php] tags.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Issue with using corporate mail server smtp function

Post by VladSun »

You've installed Outlook on the Apache machine or not?
Have you tried switching off the firewall (just for testing)?
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Issue with using corporate mail server smtp function

Post by Benjamin »

:arrow: Moved to Installation & Configuration
Doug G
Forum Contributor
Posts: 282
Joined: Sun Sep 09, 2007 6:27 pm

Re: Issue with using corporate mail server smtp function

Post by Doug G »

Are you on the corporate LAN when you're trying to use the server? If not, you're using a non-routable private IP address for the server which won't pass through the internet, and if you're on another internet ISP maybe the ISP is blocking port 25.
Post Reply