Skip to content

turboSMTP/turboSMTP-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

smtp mail server – professional SMTP service provider

turboSMTP-php SDK

The Official turboSMTP PHP SDK - enables .PHP Developers to work with turboSMTP API efficiently.

Table of contents

Release notes

Changes to the SDK beginning with version 2.0.0 (December 2024) are tracked in [CHANGELOG.md][changes-file].

Getting Started

Requirements

  • 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).

API Key

Review. Create your API Key from turboSMTP Dashboard.

Quick start with TurboSMTP Client

In order to facilitate construction and usage of TurboSMTPClientConfiguration, a TurboSMTPClientConfigurationBuilder has been facilitated implementing a Builder design pattern:

TurboSMTP Client Configuration Initialization

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();
    } 
}

TurboSMTP Client Initialization

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);                
    } 
}

TurboSMTP Client Hello World Email example

<?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.

Usage

Contribute

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:

Troubleshooting

Please see our troubleshooting guide for common library issues.

About

turboSMTP-php is maintained and funded by Turbo SMTP Company. The names and logos for turboSMTP-php are trademarks of TurboSMTP Company.

Support

If you need help using Turbo SMTP SDK, please check the TurboSMTP Support Help Center.

License

This SDK is licensed under the MIT License - see the LICENSE file for details.

About

The Official turboSMTP PHP SDK - API Library

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages