This is an example of how to set up a PHP application to send emails via SendGrid on Kinsta’s Application Hosting services, deployed from a GitHub repository.

Kinsta does not natively support outbound emails from servers. Sending emails through specialized outbound providers such as SendGrid or Mailchimp offers more flexibility and higher success rates for transactional and campaign emails.

  1. Log in to GitHub and create a new repository from this template (Use this template > Create a new repository): Kinsta – Hello World – Email Sending With PHP.
  2. In MyKinsta, add an application with the Hello World Email PHP repository. In Environment variables, add the following:
    • SENDGRID_API_KEY: The API key from SendGrid.
    • TEST_EMAIL_TO_ADDRESS: The address to send the test email to.
    • TEST_EMAIL_FROM_ADDRESS: The address to send the test email from.
    • TEST_ENDPOINT: The endpoint to use as a trigger to send the test email. Please use a random string of at least 8 characters.
  3. The Start command can be left blank for the web process as Kinsta automatically detects the required command during the first deployment.

The app is available as soon as the build finishes and a Hello World page loads at your application’s URL.

PHP email sending Hello World page after successful installation.
PHP email sending Hello World page after successful installation.

Trigger an Email

Through a very simple index.php entrypoint, two endpoints are exposed; all others will return a 404:

  • /: A simple page that returns the Hello World message
  • /${TEST_ENDPOINT}: A page that triggers a test email.

To trigger an email, find the URL of your deployment on the Deployments page, append your test endpoint to this URL, and visit the page. For example, if your TEST_ENDPOINT is set to o34nifnodhni4of and your latest deployment is at, you can trigger a test email from in your browser.