diff --git a/CHANGELOG.md b/CHANGELOG.md
index 996936c7..84d3137d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,8 @@
# Changelog
+## 0.5.1 - 2015-08-24
+ * Added an example for sending mail
+
## 0.5.0 - 2015-08-24
* Massive Breaking Change
* Some basic mail fetching functions
diff --git a/Resources/wsdl/types.xsd b/Resources/wsdl/types.xsd
index cc2dec1b..9aeb8353 100644
--- a/Resources/wsdl/types.xsd
+++ b/Resources/wsdl/types.xsd
@@ -100,7 +100,7 @@
-
+
@@ -470,7 +470,7 @@
-
+
@@ -1240,25 +1240,25 @@
-
+
-
+
-
+
-
+
@@ -1446,7 +1446,7 @@
-
+
@@ -1699,7 +1699,7 @@
-
+
@@ -3603,7 +3603,7 @@
-
+
@@ -3682,14 +3682,14 @@
-
+
-
+
-
+
diff --git a/examples/mail/sendMail.php b/examples/mail/sendMail.php
new file mode 100644
index 00000000..bf7e32b8
--- /dev/null
+++ b/examples/mail/sendMail.php
@@ -0,0 +1,16 @@
+buildClient('server', 'username', 'password');
+
+
+$message = new Type\MessageType();
+$message->setBody('Some Text');
+$message->setSubject('Test Subject');
+$message->setToRecipients('Test.User-True@multrix.com');
+
+$return = $api->sendMail($message);
diff --git a/src/API/ClassMap.php b/src/API/ClassMap.php
index 9ccc09ec..1ed16757 100644
--- a/src/API/ClassMap.php
+++ b/src/API/ClassMap.php
@@ -240,7 +240,7 @@ class ClassMap
'Duration' => '\\jamesiarmes\\PEWS\\API\\Type\\DurationType',
'EffectiveRightsType' => '\\jamesiarmes\\PEWS\\API\\Type\\EffectiveRightsType',
'EmailAddressDictionaryEntryType' => '\\jamesiarmes\\PEWS\\API\\Type\\EmailAddressDictionaryEntryType',
- 'EmailAddress' => '\\jamesiarmes\\PEWS\\API\\Type\\Mailbox',
+ 'EmailAddressType' => '\\jamesiarmes\\PEWS\\API\\Type\\EmailAddressType',
'EncryptedDataContainerType' => '\\jamesiarmes\\PEWS\\API\\Type\\SharingSecurity',
'EncryptedSharedFolderDataType' => '\\jamesiarmes\\PEWS\\API\\Type\\EncryptedSharedFolderDataType',
'EndDateRecurrenceRangeType' => '\\jamesiarmes\\PEWS\\API\\Type\\EndDateRecurrenceRangeType',
@@ -292,6 +292,7 @@ class ClassMap
'KeywordStatisticsSearchResultType' => '\\jamesiarmes\\PEWS\\API\\Type\\KeywordStatisticsSearchResultType',
'MailTipsServiceConfiguration' => '\\jamesiarmes\\PEWS\\API\\Type\\MailTipsServiceConfigurationType',
'MailTips' => '\\jamesiarmes\\PEWS\\API\\Type\\MailTipsType',
+ 'EmailAddress' => '\\jamesiarmes\\PEWS\\API\\Type\\Mailbox',
'MailboxCultureType' => '\\jamesiarmes\\PEWS\\API\\Type\\MailboxCultureType',
'MailboxData' => '\\jamesiarmes\\PEWS\\API\\Type\\MailboxDataType',
'MailboxStatisticsSearchResultType' => '\\jamesiarmes\\PEWS\\API\\Type\\MailboxStatisticsSearchResultType',
diff --git a/src/API/Message/GetUserOofSettingsRequestType.php b/src/API/Message/GetUserOofSettingsRequestType.php
index 0e4e2b60..9bd528f0 100644
--- a/src/API/Message/GetUserOofSettingsRequestType.php
+++ b/src/API/Message/GetUserOofSettingsRequestType.php
@@ -8,14 +8,14 @@
*
* XSD Type: GetUserOofSettingsRequest
*
- * @method \jamesiarmes\PEWS\API\Type\Mailbox getMailbox()
- * @method GetUserOofSettingsRequestType setMailbox(\jamesiarmes\PEWS\API\Type\Mailbox $mailbox)
+ * @method \jamesiarmes\PEWS\API\Type\EmailAddressType getMailbox()
+ * @method GetUserOofSettingsRequestType setMailbox(\jamesiarmes\PEWS\API\Type\EmailAddressType $mailbox)
*/
class GetUserOofSettingsRequestType extends BaseRequestType
{
/**
- * @var \jamesiarmes\PEWS\API\Type\Mailbox
+ * @var \jamesiarmes\PEWS\API\Type\EmailAddressType
*/
protected $mailbox = null;
}
diff --git a/src/API/Message/SetUserOofSettingsRequestType.php b/src/API/Message/SetUserOofSettingsRequestType.php
index 26d80fee..ffa9a2ab 100644
--- a/src/API/Message/SetUserOofSettingsRequestType.php
+++ b/src/API/Message/SetUserOofSettingsRequestType.php
@@ -8,8 +8,8 @@
*
* XSD Type: SetUserOofSettingsRequest
*
- * @method \jamesiarmes\PEWS\API\Type\Mailbox getMailbox()
- * @method SetUserOofSettingsRequestType setMailbox(\jamesiarmes\PEWS\API\Type\Mailbox $mailbox)
+ * @method \jamesiarmes\PEWS\API\Type\EmailAddressType getMailbox()
+ * @method SetUserOofSettingsRequestType setMailbox(\jamesiarmes\PEWS\API\Type\EmailAddressType $mailbox)
* @method \jamesiarmes\PEWS\API\Type\UserOofSettings getUserOofSettings()
* @method SetUserOofSettingsRequestType setUserOofSettings(\jamesiarmes\PEWS\API\Type\UserOofSettings $userOofSettings)
*/
@@ -17,7 +17,7 @@ class SetUserOofSettingsRequestType extends BaseRequestType
{
/**
- * @var \jamesiarmes\PEWS\API\Type\Mailbox
+ * @var \jamesiarmes\PEWS\API\Type\EmailAddressType
*/
protected $mailbox = null;
diff --git a/src/API/Type.php b/src/API/Type.php
index 3ac18622..a3a94925 100644
--- a/src/API/Type.php
+++ b/src/API/Type.php
@@ -33,7 +33,7 @@ public function __call($name, $arguments)
}
if ($callType == "add" && count($arguments) == 1) {
- return $this->add($propertyName, $arguments);
+ return $this->add($propertyName, $arguments[0]);
}
if ($callType == "is" && count($arguments) == 0) {
diff --git a/src/API/Type/BodyType.php b/src/API/Type/BodyType.php
index 90df34d0..733dd74d 100644
--- a/src/API/Type/BodyType.php
+++ b/src/API/Type/BodyType.php
@@ -20,4 +20,10 @@ class BodyType extends Type
* @var string
*/
protected $bodyType = null;
+
+ public function __construct($text, $type = 'HTML')
+ {
+ $this->_ = $text;
+ $this->bodyType = $type;
+ }
}
diff --git a/src/API/Type/EmailAddressType.php b/src/API/Type/EmailAddressType.php
index 5c90bc73..e5b95532 100644
--- a/src/API/Type/EmailAddressType.php
+++ b/src/API/Type/EmailAddressType.php
@@ -2,22 +2,24 @@
namespace jamesiarmes\PEWS\API\Type;
-use jamesiarmes\PEWS\API\Type;
-
/**
* Class representing EmailAddressType
*
- *
- * XSD Type: EmailAddress
+ * Identifier for a fully resolved email address
+ * XSD Type: EmailAddressType
*
* @method string getName()
* @method EmailAddressType setName(string $name)
- * @method string getAddress()
- * @method EmailAddressType setAddress(string $address)
+ * @method string getEmailAddress()
+ * @method EmailAddressType setEmailAddress(string $emailAddress)
* @method string getRoutingType()
* @method EmailAddressType setRoutingType(string $routingType)
+ * @method string getMailboxType()
+ * @method EmailAddressType setMailboxType(string $mailboxType)
+ * @method ItemIdType getItemId()
+ * @method EmailAddressType setItemId(ItemIdType $itemId)
*/
-class EmailAddressType extends Type
+class EmailAddressType extends BaseEmailAddressType
{
/**
@@ -28,10 +30,20 @@ class EmailAddressType extends Type
/**
* @var string
*/
- protected $address = null;
+ protected $emailAddress = null;
/**
* @var string
*/
protected $routingType = null;
+
+ /**
+ * @var string
+ */
+ protected $mailboxType = null;
+
+ /**
+ * @var \jamesiarmes\PEWS\API\Type\ItemIdType
+ */
+ protected $itemId = null;
}
diff --git a/src/API/Type/ExchangeImpersonationType.php b/src/API/Type/ExchangeImpersonationType.php
index f01e8def..4e7840f7 100644
--- a/src/API/Type/ExchangeImpersonationType.php
+++ b/src/API/Type/ExchangeImpersonationType.php
@@ -15,18 +15,19 @@
*/
class ExchangeImpersonationType extends Type
{
+
+ /**
+ * @var \jamesiarmes\PEWS\API\Type\ConnectingSIDType
+ */
+ protected $connectingSID = null;
+
public static function fromEmailAddress($emailAddress)
{
- $impersonation = new static();
+ $impersonation = new self();
$connectingSID = new ConnectingSIDType();
$connectingSID->setPrimarySmtpAddress($emailAddress);
$impersonation->setConnectingSID($connectingSID);
return $impersonation;
}
-
- /**
- * @var \jamesiarmes\PEWS\API\Type\ConnectingSIDType
- */
- protected $connectingSID = null;
}
diff --git a/src/API/Type/MessageType.php b/src/API/Type/MessageType.php
index 9b956ac7..27460692 100644
--- a/src/API/Type/MessageType.php
+++ b/src/API/Type/MessageType.php
@@ -10,9 +10,7 @@
*
* @method SingleRecipientType getSender()
* @method MessageType setSender(SingleRecipientType $sender)
- * @method MessageType addToRecipients(EmailAddressType $toRecipients)
* @method EmailAddressType[] getToRecipients()
- * @method MessageType setToRecipients(array $toRecipients)
* @method MessageType addCcRecipients(EmailAddressType $ccRecipients)
* @method EmailAddressType[] getCcRecipients()
* @method MessageType setCcRecipients(array $ccRecipients)
@@ -139,4 +137,43 @@ public function isAReply()
{
return ($this->exists('inReplyTo') && $this->getInReplyTo() !== null);
}
+
+ /**
+ * @param BodyType|string $body
+ * @return MessageType
+ */
+ public function setBody($body)
+ {
+ if (is_string($body)) {
+ $body = new BodyType($body);
+ }
+
+ return parent::setBody($body);
+ }
+
+ public function addToRecipients($recipient)
+ {
+ if (is_string($recipient)) {
+ $address = new Mailbox();
+ $address->setEmailAddress($recipient);
+ $recipient = $address;
+ }
+
+ return parent::addToRecipients($recipient);
+ }
+
+ public function setToRecipients($recipients)
+ {
+ $this->toRecipients = [ ];
+
+ if (!is_array($recipients)) {
+ $recipients = array($recipients);
+ }
+
+ foreach ($recipients as $recipient) {
+ $this->addToRecipients($recipient);
+ }
+
+ return $this;
+ }
}
diff --git a/src/Generator/ConvertToPHP.php b/src/Generator/ConvertToPHP.php
index fa2b96b8..f851898c 100644
--- a/src/Generator/ConvertToPHP.php
+++ b/src/Generator/ConvertToPHP.php
@@ -104,6 +104,14 @@ function ($type) use ($schemas) {
}
);
+ $converter->addAliasMap(
+ 'http://schemas.microsoft.com/exchange/services/2006/types',
+ 'EmailAddress',
+ function ($type) use ($schemas) {
+ return "jamesiarmes\\PEWS\\API\\Type\\EmailAddressType";
+ }
+ );
+
$items = $converter->convert($schemas);
$progress->start($output, count($items));
$classMap = [];
diff --git a/src/Generator/PhpConverter.php b/src/Generator/PhpConverter.php
index 5d8d3c83..433fab57 100644
--- a/src/Generator/PhpConverter.php
+++ b/src/Generator/PhpConverter.php
@@ -38,27 +38,27 @@ public function __construct(NamingStrategy $namingStrategy)
parent::__construct($namingStrategy);
$this->addAliasMap("http://www.w3.org/2001/XMLSchema", "dateTime", function (Type $type) {
-
+
return "DateTime";
});
$this->addAliasMap("http://www.w3.org/2001/XMLSchema", "time", function (Type $type) {
-
+
return "DateTime";
});
$this->addAliasMap("http://www.w3.org/2001/XMLSchema", "date", function (Type $type) {
-
+
return "DateTime";
});
$this->addAliasMap("http://www.w3.org/2001/XMLSchema", "anySimpleType", function (Type $type) {
-
+
return "mixed";
});
$this->addAliasMap("http://www.w3.org/2001/XMLSchema", "anyType", function (Type $type) {
-
+
return "mixed";
});
$this->addAliasMap("http://www.w3.org/2001/XMLSchema", "base64Binary", function (Type $type) {
-
+
return "string";
});
}
@@ -82,7 +82,7 @@ public function convert(array $schemas)
private function getTypes()
{
uasort($this->classes, function ($a, $b) {
-
+
return strcmp($a["class"]->getFullName(), $b["class"]->getFullName());
});
$ret = array();
diff --git a/src/Mail/MailAPI.php b/src/Mail/MailAPI.php
index 8807ab4f..760949a2 100644
--- a/src/Mail/MailAPI.php
+++ b/src/Mail/MailAPI.php
@@ -5,6 +5,7 @@
use jamesiarmes\PEWS\API;
use jamesiarmes\PEWS\API\Type;
use \DateTime;
+use jamesiarmes\PEWS\API\Type\MessageType;
class MailAPI extends API
{
@@ -111,4 +112,12 @@ public function markMailAsRead($mailItem)
'IsRead' => true
));
}
+
+ public function sendMail(MessageType $message)
+ {
+ $items = array('Message' => $message->toXmlObject() );
+ $options = array ('MessageDisposition' => 'SendAndSaveCopy' );
+
+ return $this->createItems($items, $options);
+ }
}