# Email

To get started you need to ensure that you have setup the email variables on your **`.env`** file. Also you have a logo on your **`/uploads/app/`** folder that will also the set on the .env file as **`APP_LOGO`** variable.

Check out more on env here;

{% content-ref url="broken-reference" %}
[Broken link](https://simcycreative.gitbook.io/signer/php-functions/email-and-sms/broken-reference)
{% endcontent-ref %}

## Parameters

| Parameter     | Required | Type         | Description                                                                                                         |
| ------------- | -------- | ------------ | ------------------------------------------------------------------------------------------------------------------- |
| $to           | Yes      | **`string`** | Email of the recipient.                                                                                             |
| $subject      | Yes      | **`string`** | Subject of the email                                                                                                |
| $view\_data   | Yes      | **`array`**  | Array of data to print on the template. The structure of each template is explained below.                          |
| $view\_name   | No       | **`string`** | The name of the template file in the /views/email/html folder without extension. e.g basic \| withbutton \| invoice |
| $from         | No       | **`string`** | Where the email is from e.g Simcy Creative <<hello@simcycreative.com>>                                              |
| $attachements | No       | **`array`**  | array with full paths files to attach.                                                                              |

## Usage

```php
use Simcify\Mail;

Mail::send(
    "john@example.com",
    "Thank you for your purchase!"
    array(
        "message" => "Your order has been received and is being processed",
    ),
    "basic"
);
```

{% hint style="info" %}
All **`$view_data`** values are required depending on the template.
{% endhint %}

### Basic template&#x20;

#### screenshot

<div align="left"><img src="https://3853823144-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LOYk-FnMQUtSr8MWLk1%2F-LS1CvqzP6zrfleb-Uyj%2F-LS1FpVw1eK93ZeHu-OY%2Fbasic.png?alt=media&#x26;token=2e4c4671-ffaf-4333-9db5-e57d627df0c3" alt=""></div>

#### Sample array

```php
array(
    "message" => "Hello there, how are you?"
)
```

All array values are required.

| Variable | Type   | Description                   |
| -------- | ------ | ----------------------------- |
| message  | string | The message to send on email. |

###

### &#x20;Template with button&#x20;

#### screenshot

<div align="left"><img src="https://3853823144-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LOYk-FnMQUtSr8MWLk1%2F-LS1CvqzP6zrfleb-Uyj%2F-LS1GNDkzZNeiLgMUAly%2Fwithbutton.png?alt=media&#x26;token=6d36f97d-65ce-4b24-9fbb-fac3042273aa" alt=""></div>

#### Sample array

```php
array(
    "title" => "Password reset",
    "subtitle" => "Click the button below to reset password",
    "buttonText" => "Reset Password",
    "buttonLink" => "https://example.com/reset"
    "message" => "Someone hopefully you asked for...."
)
```

All array values are required.

| Variable   | Type         | Description                   |
| ---------- | ------------ | ----------------------------- |
| title      | **`string`** | The title of the email        |
| subtitle   | **`string`** | The email subtitle            |
| buttonText | **`string`** | The label of the button       |
| buttonLink | **`string`** | The link of the button        |
| message    | **`string`** | The message to send on email. |

### Invoice Template&#x20;

#### screenshot

<div align="left"><img src="https://3853823144-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LOYk-FnMQUtSr8MWLk1%2F-LS1J7rpFRkOs_jUNJp_%2F-LS1JHfwiYi7RlDz4fLY%2Finvoice.png?alt=media&#x26;token=7e70891f-9040-41d1-8fcc-3403faa6361f" alt=""></div>

#### Sample array

```php
array(
    "title" => "Thank you for your purchase!",
    "subtitle" => "Your order has been received and is being processed",
    "summary" => array(
                    "currency" => "$",
                    "subtotal" => "243.6",
                    "tax" => "3.6",
                    "total" => "246.6",
                ),
    "items" => array(
                array(
                    "name" => "Socks",
                    "quantity" => "2",
                    "price" => "34.5",
                ),
                array(
                    "name" => "Green Bag",
                    "quantity" => "1",
                    "price" => "25.7",
                ),
                array(
                    "name" => "Sweat Pants",
                    "quantity" => "5",
                    "price" => "19.6",
                )
            )
)
```

All array values are required.

| Variable | Type         | Description                                                                                       |
| -------- | ------------ | ------------------------------------------------------------------------------------------------- |
| title    | **`string`** | The title of the email                                                                            |
| subtitle | **`string`** | The email subtitle                                                                                |
| summary  | **`array`**  | This is an array containing: currency, subtotal, total & tax                                      |
| items    | **`array`**  | This is an array of items with array of item details. Each array will have name, quantity & price |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://simcycreative.gitbook.io/signer/php-functions/email-and-sms/email.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
