<commit_before># Sendgrid-php

This library allows you to quickly and easily send emails through SendGrid using PHP.

Important: This library requires PHP 5.3 or higher.

[![BuildStatus](https://travis-ci.org/sendgrid/sendgrid-php.png?branch=master)](https://travis-ci.org/sendgrid/sendgrid-php)

```php
$sendgrid = new SendGrid('username', 'password');
$mail     = new SendGrid\Mail();
$mail->addTo('<EMAIL>')->
       addTo('<EMAIL>')->
       setFrom('<EMAIL>')->
       setSubject('Subject goes here')->
       setText('Hello World!')->
       setHtml('<strong>Hello World!</strong>');

$sendgrid->web->send($mail);
```

## Installation

The following recommended installation requires [composer](http://getcomposer.org/). If you are unfamiliar with composer see the [composer installation instructions](http://getcomposer.org/doc/01-basic-usage.md#installation).

Add the following to your `composer.json` file:

```json
{  
  "require": {
    "sendgrid/sendgrid": "1.0.9"
  }
}
```

Install sendgrid-php and its dependencies:

```bash
composer install
```

Load sendgrid-php and its dependencies into your project:

```php
require 'vendor/autoload.php';
```

### Alternative Installation

If you choose not to use composer you can do the following alternative installation using git:

```bash
git clone https://github.com/sendgrid/sendgrid-php.git
```

Then require the autoloader from your php script:

```php
require '../path/to/sendgrid-php/SendGrid_loader.php';
```

Finally, install SwiftMailer using pear.

```bash
pear channel-discover pear.swiftmailer.org
pear install swift/swift
```

*IMPORTANT: If you do not plan on sending using SMTP, you can skip installation of swiftmailer.* In which case your send line of code will look like this.

```php
$sendgrid->web->send($mail);
```

## SendGrid APIs ##

SendGrid provides two methods of sending email: the Web API, and SMTP API.  SendGrid recommends using the SMTP API for sending emails.
For an explanation of the benefits of each, refer to http://docs.sendgrid.com/documentation/get-started/integrate/examples/smtp-vs-rest/.

This library implements a common interface to make it very easy to use either API.

## Pre-Usage ##

Before we begin using the library, its important to understand a few things about the library architecture...

* The SendGrid Mail object is the means of setting mail data. In general, data can be set in three ways for most elements:
  1. set - reset the data, and initialize it to the given element. This will destroy previous data
  2. set (List) - for array based elements, we provide a way of passing the entire array in at once. This will also destroy previous data.  3. add - append data to the list of elements.  
* Sending an email is as simple as :
  1. Creating a SendGrid Instance
  1. Creating a SendGrid Mail object, and setting its data
  1. Sending the mail using either SMTP API or Web API.

## Usage

To begin using this library, initialize the SendGrid object with your SendGrid credentials.

```php
$sendgrid = new SendGrid('username', 'password');
```
<commit_msg>A little bit clearer<commit_after># Sendgrid-php

This library allows you to quickly and easily send emails through SendGrid using PHP.

Important: This library requires PHP 5.3 or higher.

[![BuildStatus](https://travis-ci.org/sendgrid/sendgrid-php.png?branch=master)](https://travis-ci.org/sendgrid/sendgrid-php)

```php
$sendgrid = new SendGrid('username', 'password');
$mail     = new SendGrid\Mail();
$mail->addTo('<EMAIL>')->
       addTo('<EMAIL>')->
       setFrom('<EMAIL>')->
       setSubject('Subject goes here')->
       setText('Hello World!')->
       setHtml('<strong>Hello World!</strong>');

$sendgrid->web->send($mail);
```

## Installation

The following recommended installation requires [composer](http://getcomposer.org/). If you are unfamiliar with composer see the [composer installation instructions](http://getcomposer.org/doc/01-basic-usage.md#installation).

Add the following to your `composer.json` file:

```json
{  
  "require": {
    "sendgrid/sendgrid": "1.0.9"
  }
}
```

Install sendgrid-php and its dependencies:

```bash
composer install
```

Load sendgrid-php and its dependencies into your project:

```php
require 'vendor/autoload.php';
```

### Alternative Installation

If you choose not to use composer you can do the following alternative installation using git:

```bash
git clone https://github.com/sendgrid/sendgrid-php.git
```

Then require the autoloader from your php script:

```php
require '../path/to/sendgrid-php/SendGrid_loader.php';
```

Finally, install SwiftMailer using pear.

```bash
pear channel-discover pear.swiftmailer.org
pear install swift/swift
```

*IMPORTANT: If you do not plan on sending using SMTP, you can skip installation of swiftmailer.* In which case your send line of code will look like this.

```php
$sendgrid->web->send($mail);
```

Instead of this.

```php
$sendgrid->smtp->send($mail);
```

## SendGrid APIs ##

SendGrid provides two methods of sending email: the Web API, and SMTP API.  SendGrid recommends using the SMTP API for sending emails.
For an explanation of the benefits of each, refer to http://docs.sendgrid.com/documentation/get-started/integrate/examples/smtp-vs-rest/.

This library implements a common interface to make it very easy to use either API.

## Pre-Usage ##

Before we begin using the library, its important to understand a few things about the library architecture...

* The SendGrid Mail object is the means of setting mail data. In general, data can be set in three ways for most elements:
  1. set - reset the data, and initialize it to the given element. This will destroy previous data
  2. set (List) - for array based elements, we provide a way of passing the entire array in at once. This will also destroy previous data.  3. add - append data to the list of elements.  
* Sending an email is as simple as :
  1. Creating a SendGrid Instance
  1. Creating a SendGrid Mail object, and setting its data
  1. Sending the mail using either SMTP API or Web API.

## Usage

To begin using this library, initialize the SendGrid object with your SendGrid credentials.

```php
$sendgrid = new SendGrid('username', 'password');
```

{'fraction_non_alphanumeric': 0.11187911911268285, 'fraction_numerical': 0.004179392380646198, 'mean_word_length': 4.154929577464789, 'pattern_counts': {'":': 4, '<': 13, '<?xml version=': 0, '>': 35, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '997092', 'n_tokens_mistral': 1841, 'n_tokens_neox': 1761, 'n_words': 730}