Need help connecting to Exchange
Posted: Tue May 29, 2007 6:34 pm
I've been playing with this for the last 4 days.
Trying to connect to Exchange and have had no luck.
---------------------------------------------
-- This is the output on the screen --
---------------------------------------------
Swift_Connection_SMTP Object
(
[handle:protected] =>
[port:protected] => 1097
[encryption:protected] => 8
[timeout:protected] => 2
[username:protected] => MyUserName
[password:protected] => MyPassword
[authenticators:protected] => Array
(
)
[errno:protected] =>
[errstr:protected] =>
[extensions:protected] => Array
(
)
[isESMTP:protected] => 1
[server] => 10.134.9.103
)
There was a problem communicating with SMTP: There was a problem reading line 1 of an SMTP response.
The response so far was:[].
It appears the connection has died without saying goodbye to us! Too many emails in one go perhaps? (fsockopen: #0)
---------------------------------------------
The classes loaded:
---------------------------------------------
Array
(
[0] => stdClass
[1] => Exception
[2] => ErrorException
[3] => COMPersistHelper
[4] => com_exception
[5] => com_safearray_proxy
[6] => variant
[7] => com
[8] => dotnet
[9] => ReflectionException
[10] => Reflection
[11] => ReflectionFunctionAbstract
[12] => ReflectionFunction
[13] => ReflectionParameter
[14] => ReflectionMethod
[15] => ReflectionClass
[16] => ReflectionObject
[17] => ReflectionProperty
[18] => ReflectionExtension
[19] => DateTime
[20] => DateTimeZone
[21] => LibXMLError
[22] => __PHP_Incomplete_Class
[23] => php_user_filter
[24] => Directory
[25] => SimpleXMLElement
[26] => DOMException
[27] => DOMStringList
[28] => DOMNameList
[29] => DOMImplementationList
[30] => DOMImplementationSource
[31] => DOMImplementation
[32] => DOMNode
[33] => DOMNameSpaceNode
[34] => DOMDocumentFragment
[35] => DOMDocument
[36] => DOMNodeList
[37] => DOMNamedNodeMap
[38] => DOMCharacterData
[39] => DOMAttr
[40] => DOMElement
[41] => DOMText
[42] => DOMComment
[43] => DOMTypeinfo
[44] => DOMUserDataHandler
[45] => DOMDomError
[46] => DOMErrorHandler
[47] => DOMLocator
[48] => DOMConfiguration
[49] => DOMCdataSection
[50] => DOMDocumentType
[51] => DOMNotation
[52] => DOMEntity
[53] => DOMEntityReference
[54] => DOMProcessingInstruction
[55] => DOMStringExtend
[56] => DOMXPath
[57] => RecursiveIteratorIterator
[58] => IteratorIterator
[59] => FilterIterator
[60] => RecursiveFilterIterator
[61] => ParentIterator
[62] => LimitIterator
[63] => CachingIterator
[64] => RecursiveCachingIterator
[65] => NoRewindIterator
[66] => AppendIterator
[67] => InfiniteIterator
[68] => RegexIterator
[69] => RecursiveRegexIterator
[70] => EmptyIterator
[71] => ArrayObject
[72] => ArrayIterator
[73] => RecursiveArrayIterator
[74] => SplFileInfo
[75] => DirectoryIterator
[76] => RecursiveDirectoryIterator
[77] => SplFileObject
[78] => SplTempFileObject
[79] => SimpleXMLIterator
[80] => LogicException
[81] => BadFunctionCallException
[82] => BadMethodCallException
[83] => DomainException
[84] => InvalidArgumentException
[85] => LengthException
[86] => OutOfRangeException
[87] => RuntimeException
[88] => OutOfBoundsException
[89] => OverflowException
[90] => RangeException
[91] => UnderflowException
[92] => UnexpectedValueException
[93] => SplObjectStorage
[94] => XMLReader
[95] => XMLWriter
[96] => mysqli_sql_exception
[97] => mysqli_driver
[98] => mysqli
[99] => mysqli_warning
[100] => mysqli_result
[101] => mysqli_stmt
[102] => PDOException
[103] => PDO
[104] => PDOStatement
[105] => PDORow
[106] => SQLiteDatabase
[107] => SQLiteResult
[108] => SQLiteUnbuffered
[109] => SQLiteException
[110] => Swift
[111] => Swift_ClassLoader
[112] => Swift_Connection_Exception
[113] => Swift_ConnectionBase
[114] => Swift_BadResponseException
[115] => Swift_Cache
[116] => Swift_CacheFactory
[117] => Swift_AddressContainer
[118] => Swift_Address
[119] => Swift_Message_Mime
[120] => Swift_File
[121] => Swift_FileException
[122] => Swift_Message_MimeException
[123] => Swift_Message_Attachment
[124] => Swift_Message_EmbeddedFile
[125] => Swift_Message_Image
[126] => Swift_Message_Part
[127] => Swift_Message
[128] => Swift_RecipientList
[129] => Swift_Iterator_Array
[130] => Swift_BatchMailer
[131] => Swift_Events
[132] => Swift_Connection_SMTP
)
---------------------------------------------
My code
---------------------------------------------
---------------------------------------------
I can connect to GMAIL at my home computer, but at work I'm behind a firewall, so I have to connect to the Exchange to the local network.
Any help would be greatly appreciated as I can not seem to connect to the Exchange and get any emails going.
Please help.
Thank you in advance.
Trying to connect to Exchange and have had no luck.
---------------------------------------------
-- This is the output on the screen --
---------------------------------------------
Swift_Connection_SMTP Object
(
[handle:protected] =>
[port:protected] => 1097
[encryption:protected] => 8
[timeout:protected] => 2
[username:protected] => MyUserName
[password:protected] => MyPassword
[authenticators:protected] => Array
(
)
[errno:protected] =>
[errstr:protected] =>
[extensions:protected] => Array
(
)
[isESMTP:protected] => 1
[server] => 10.134.9.103
)
There was a problem communicating with SMTP: There was a problem reading line 1 of an SMTP response.
The response so far was:[].
It appears the connection has died without saying goodbye to us! Too many emails in one go perhaps? (fsockopen: #0)
---------------------------------------------
The classes loaded:
---------------------------------------------
Array
(
[0] => stdClass
[1] => Exception
[2] => ErrorException
[3] => COMPersistHelper
[4] => com_exception
[5] => com_safearray_proxy
[6] => variant
[7] => com
[8] => dotnet
[9] => ReflectionException
[10] => Reflection
[11] => ReflectionFunctionAbstract
[12] => ReflectionFunction
[13] => ReflectionParameter
[14] => ReflectionMethod
[15] => ReflectionClass
[16] => ReflectionObject
[17] => ReflectionProperty
[18] => ReflectionExtension
[19] => DateTime
[20] => DateTimeZone
[21] => LibXMLError
[22] => __PHP_Incomplete_Class
[23] => php_user_filter
[24] => Directory
[25] => SimpleXMLElement
[26] => DOMException
[27] => DOMStringList
[28] => DOMNameList
[29] => DOMImplementationList
[30] => DOMImplementationSource
[31] => DOMImplementation
[32] => DOMNode
[33] => DOMNameSpaceNode
[34] => DOMDocumentFragment
[35] => DOMDocument
[36] => DOMNodeList
[37] => DOMNamedNodeMap
[38] => DOMCharacterData
[39] => DOMAttr
[40] => DOMElement
[41] => DOMText
[42] => DOMComment
[43] => DOMTypeinfo
[44] => DOMUserDataHandler
[45] => DOMDomError
[46] => DOMErrorHandler
[47] => DOMLocator
[48] => DOMConfiguration
[49] => DOMCdataSection
[50] => DOMDocumentType
[51] => DOMNotation
[52] => DOMEntity
[53] => DOMEntityReference
[54] => DOMProcessingInstruction
[55] => DOMStringExtend
[56] => DOMXPath
[57] => RecursiveIteratorIterator
[58] => IteratorIterator
[59] => FilterIterator
[60] => RecursiveFilterIterator
[61] => ParentIterator
[62] => LimitIterator
[63] => CachingIterator
[64] => RecursiveCachingIterator
[65] => NoRewindIterator
[66] => AppendIterator
[67] => InfiniteIterator
[68] => RegexIterator
[69] => RecursiveRegexIterator
[70] => EmptyIterator
[71] => ArrayObject
[72] => ArrayIterator
[73] => RecursiveArrayIterator
[74] => SplFileInfo
[75] => DirectoryIterator
[76] => RecursiveDirectoryIterator
[77] => SplFileObject
[78] => SplTempFileObject
[79] => SimpleXMLIterator
[80] => LogicException
[81] => BadFunctionCallException
[82] => BadMethodCallException
[83] => DomainException
[84] => InvalidArgumentException
[85] => LengthException
[86] => OutOfRangeException
[87] => RuntimeException
[88] => OutOfBoundsException
[89] => OverflowException
[90] => RangeException
[91] => UnderflowException
[92] => UnexpectedValueException
[93] => SplObjectStorage
[94] => XMLReader
[95] => XMLWriter
[96] => mysqli_sql_exception
[97] => mysqli_driver
[98] => mysqli
[99] => mysqli_warning
[100] => mysqli_result
[101] => mysqli_stmt
[102] => PDOException
[103] => PDO
[104] => PDOStatement
[105] => PDORow
[106] => SQLiteDatabase
[107] => SQLiteResult
[108] => SQLiteUnbuffered
[109] => SQLiteException
[110] => Swift
[111] => Swift_ClassLoader
[112] => Swift_Connection_Exception
[113] => Swift_ConnectionBase
[114] => Swift_BadResponseException
[115] => Swift_Cache
[116] => Swift_CacheFactory
[117] => Swift_AddressContainer
[118] => Swift_Address
[119] => Swift_Message_Mime
[120] => Swift_File
[121] => Swift_FileException
[122] => Swift_Message_MimeException
[123] => Swift_Message_Attachment
[124] => Swift_Message_EmbeddedFile
[125] => Swift_Message_Image
[126] => Swift_Message_Part
[127] => Swift_Message
[128] => Swift_RecipientList
[129] => Swift_Iterator_Array
[130] => Swift_BatchMailer
[131] => Swift_Events
[132] => Swift_Connection_SMTP
)
---------------------------------------------
My code
---------------------------------------------
Code: Select all
<?php
$APP_FRAMEWORK_DIR = $_SERVER['DOCUMENT_ROOT'] . '/framework';
$PEAR = $_SERVER['DOCUMENT_ROOT'] . '/PEAR';
$PHPLIB = $_SERVER['DOCUMENT_ROOT'] . '/phplib';
$SWIFTLIB = $_SERVER['DOCUMENT_ROOT'] . '/swiftlib/';
$SWIFTLIB_CON = $_SERVER['DOCUMENT_ROOT'] . '/swiftlib/Swift/Connection/';
// Insert the path in the PHP include_path so that PHP
// looks for PEAR, PHPLIB and our application framework
// classes in these directories
ini_set( 'include_path', ';' .
$PEAR . ';' .
$PHPLIB . ';' .
$APP_FRAMEWORK_DIR . ';' .
$SWIFTLIB . ';' .
$SWIFTLIB_CON . ';' .
ini_get('include_path'));
//Load in the files we'll need
require_once "Swift.php";
require_once "SMTP.php";
print_r(get_declared_classes()); // This is for debugging purposes only
try
{
$smtp = new Swift_Connection_SMTP('10.134.9.103', 1097);
$smtp->setUsername("MyUserName");
$smtp->setPassword("MyPassword");
print_r($smtp); // This is for debugging purposes only
$swift = new Swift($smtp);
//Create a message
$message = new Swift_Message("My subject");
$message->setContentType("text/html");
//Add some "parts"
$message->attach(new Swift_Message_Part("Part 1 of message"));
$message->attach(new Swift_Message_Part("Part <strong>2</strong> of message"));
//Start a new list
$recipients = new Swift_RecipientList();
$recipients->addTo("alfredo.otero@gmail.com"); //or we can just add the address
$result = $swift->send($message,
$recipients,
new Swift_Address("alfredo.otero@myserver.com", "WebMaster") // Sender
);
if (!$result)
{
echo "error: ";
}
$swift->disconnect();
print_r($message); // This is for debugging purposes only
}
catch (Swift_Connection_Exception $e)
{
echo "There was a problem communicating with SMTP:<br> " . $e->getMessage() . "<br>";
}
catch (Swift_Message_MimeException $e)
{
echo "There was an unexpected problem building the email:<br> " . $e->getMessage() . "<br>";
}
?>I can connect to GMAIL at my home computer, but at work I'm behind a firewall, so I have to connect to the Exchange to the local network.
Any help would be greatly appreciated as I can not seem to connect to the Exchange and get any emails going.
Please help.
Thank you in advance.