The Official turboSMTP PHP SDK - enables .PHP Developers to work with turboSMTP API efficiently.
- Release notes
- Getting Started
- Quick start with TurboSMTP Client
- Usage
- Contribute
- Troubleshooting
- About
- Support
- License
Changes to the SDK beginning with version 2.0.0 (December 2024) are tracked in [CHANGELOG.md][changes-file].
- PHP 8.3+.
- A turboSMTP account, sign up for free to send up to 6.000 FREE emails per month (No Obligation - No Credit card required).
Review. Create your API Key from turboSMTP Dashboard.
In order to facilitate construction and usage of TurboSMTPClientConfiguration, a TurboSMTPClientConfigurationBuilder has been facilitated implementing a Builder design pattern:
As stated above, TurboSMTPClientConfiguration uses a builder design pattern (TurboSMTPClientConfigurationBuilder) that allows to setup your ConsumerKey and Secret, option for EuropeanUser and your Timezone that will be used to consume time sensitive data, like when filtering data by dates.
<?php
namespace SampleNameSpace;
use TurboSMTP\TurboSMTPClientConfigurationBuilder;
class Sample
{
public function sample_method()
{
$configurationBuilder = new TurboSMTPClientConfigurationBuilder();
$configuration = $configurationBuilder
->setConsumerKey(AppConstants::ConsumerKey)
->setConsumerSecret(AppConstants::ConsumerSecret)
->setEuropeanUser(AppConstants::EuropeanUser)
->build();
}
}In order to create a TurboSMTPClient simply pass a TurboSMTPClientConfiguration to it´s constructor as:
<?php
namespace SampleNameSpace;
use TurboSMTP\TurboSMTPClientConfigurationBuilder;
use TurboSMTP\TurboSMTPClient;
class Sample
{
public function sample_method()
{
$configurationBuilder = new TurboSMTPClientConfigurationBuilder();
$configuration = $configurationBuilder
->setConsumerKey(AppConstants::ConsumerKey)
->setConsumerSecret(AppConstants::ConsumerSecret)
->setEuropeanUser(AppConstants::EuropeanUser)
->build();
$ts_client = new TurboSMTPClient($configuration);
}
}<?php
namespace SampleNameSpace;
use TurboSMTP\TurboSMTPClientConfigurationBuilder;
use TurboSMTP\TurboSMTPClient;
use TurboSMTP\Domain\EmailMessage\EmailMessageBuilder;
class Sample
{
public function sample_method()
{
$configurationBuilder = new TurboSMTPClientConfigurationBuilder();
$configuration = $configurationBuilder
->setConsumerKey(AppConstants::ConsumerKey)
->setConsumerSecret(AppConstants::ConsumerSecret)
->setEuropeanUser(AppConstants::EuropeanUser)
->build();
$ts_client = new TurboSMTPClient($configuration);
$emailBuilder = new EmailMessageBuilder();
// Build the email message
$emailMessage = $emailBuilder
->setFrom('sender@yourdomain.com')
->addTo('recipient@domain.com')
->setSubject('Hello World Simple Email')
->setHtmlContent('This email has been sent using <b>turboSMTP SDK</b>.')
->build(); // Call build to get the EmailMessage instance
//Send the Email Message.
$result = $ts_client->getEmailMessages()->SendAsync($emailMessage)->wait();
//Print the returned message ID.
echo $result->getMessageID();
}
}After executing the above code, $result->getMessage() should be OK and $result->getMessageID() should contain a reference number to your sending operation, and you should have an email in the inbox of the to recipient. You can check the status of your email in the UI, or using TurboSMTPClient->getRelays()->queryAsync() method. Alternatively, we can post events to a URL of your choice using our Event Webhooks. This gives you information about the events that occur as turboSMTP processes your email.
Thank you for considering contributing to our SDK! We welcome all forms of contributions, including bug reports and feature requests.
Your feedback is invaluable in helping us improve and expand our SDK, please refere to our CONTRIBUTING guide for details.
For any inquiries, you can contact us at the following email address:
Email: sdk@turbo-smtp
Quick links:
Please see our troubleshooting guide for common library issues.
turboSMTP-php is maintained and funded by Turbo SMTP Company. The names and logos for turboSMTP-php are trademarks of TurboSMTP Company.
If you need help using Turbo SMTP SDK, please check the TurboSMTP Support Help Center.
This SDK is licensed under the MIT License - see the LICENSE file for details.