Send Email using ProfitBricks IaaS

SendGridLogoThe following post was written by our friend Adam DuVander, who is the Developer Communications Director at SendGrid.

ProfitBricks provides Infrastructure-as-a-Service allowing developers to design “virtual data centers.” The core offerings include computing and redundant block storage. As a ProfitBricks partner, SendGrid helps developers send email from their virtual data centers. In the tutorial below, you’ll see how easy it is to send email with SendGrid and ProfitBricks.

Before you continue, make sure you have accounts on both services. You can signup for ProfitBricks and also create a SendGrid account if you don’t have one already.

Though ProfitBricks has a visual Datacenter Designer, we’ll use the Command-Line Interface(CLI). Once installed, add your ProfitBricks username and password to default.auth and start the CLI:


Now you’re ready to create a datacenter, add storage, connect a server and then send email.

Create a Datacenter

From within the CLI, run the following command:





Create Storage

To create a storage run the following command:





Connect a Server to Storage

To create a server run the following command:




After you run the create-server command you need to wait until your server is created and OS image is installed on storage. When finished, you can get details about your server, including IP address for SSH:


After creating the server you should receive an email with the username/password for it. Use that combination to login via SSH to install PHP and git:


Now you’re ready for your application, including SendGrid.

Send Email with SendGrid

Since we’re using PHP, you can you the SendGrid PHP library or clone it directly using git:


Within your application, you’ll need to include the SendGrid library:


Then send an email:


With just a few lines of code, you have email sending from ProfitBricks.