We have two samples available that allow a user to input all of the parameters required by the API in order to send out an email message.
PHP Sample #1: Send a Mass Email - allows a user to send a mass email to a specified group that is in their account using the SendMassEmail method at http://api.jangomail.com/api.asmx?op=SendMassEmail
<?php
$client = new SoapClient('https://api.jangomail.com/api.asmx?WSDL');
$parameters = array
(
'Username' => (string) 'username',
'Password' => (string) 'password',
'FromEmail' => (string) 'fromaddress@domain.com',
'FromName' => (string) 'name',
'ToGroups' => (string) 'group name',
'ToGroupFilter' => (string) '',
'ToOther' => (string) '',
'ToWebDatabase' => (string) '',
'Subject' => (string) 'Mass Subject',
'MessagePlain' => (string) 'Mass Plain (plain text)',
'MessageHTML' => (string) 'Mass HTML (html) <br><a href="http://www.google.com">Link #1</a>',
'Options' => (string) 'OpenTrack=True,ClickTrack=True'
);
try
{
$response = $client->SendMassEmail($parameters);
echo "Message(s) sent!";
}
catch(SoapFault $e)
{
echo $client->__getLastRequest();
}
?>
PHP Sample #2: Send a Transactional Email - allows a user to send a transactional email to a recipient that they specify using the SendTransactionalEmail method at http://api.jangomail.com/api.asmx?op=SendTransactionalEmail
<?php
$client = new SoapClient('https://api.jangomail.com/api.asmx?WSDL');
$parameters = array
(
'Username' => (string) 'username',
'Password' => (string) 'password',
'FromEmail' => (string) 'fromaddress@domain.com',
'FromName' => (string) 'name',
'ToEmailAddress' => (string) 'recipient@domain.com',
'Subject' => (string) 'Transactional Subject',
'MessagePlain' => (string) 'Transactional Plain (plain text)',
'MessageHTML' => (string) '<b>Transactional HTML</b> (html)',
'Options' => (string) 'OpenTrack=True,ClickTrack=True'
);
try
{
$response = $client->SendTransactionalEmail($parameters);
echo "Message(s) sent!";
}
catch(SoapFault $e)
{
echo $client->__getLastRequest();
}
?>
Awesome! I have looking for something just like this...
ReplyDeleteUsing the JangoMail API in PHP applications has been a very smooth experience, the API documentation and fast responses from the JangoMail support team made a huge difference during the development process.
ReplyDeletewow the technical support seems to be online at any time !!
ReplyDeleteFatal error: Class 'SoapClient' not found in C:\wamp\www\mail.php on line 3
ReplyDeleteI got this error while executing this code
When receiving an error stating that the 'SoapClient' Class could not be found, it typically means that it's not installed on your web server. You should check with your web hosting provider to see if they can make this available. Some web hosting providers allow you to switch the version of PHP you're using with your account as well, and I've found that some higher versions already have this installed.
ReplyDelete