Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions _data/toc/graphql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ pages:
- label: revokeCustomerToken mutation
url: /graphql/mutations/revoke-customer-token.html

- label: sendEmailToFriend mutation
url: /graphql/mutations/send-email-to-friend.html

- label: setBillingAddressesOnCart mutation
url: /graphql/mutations/set-billing-address.html

Expand Down
129 changes: 129 additions & 0 deletions guides/v2.3/graphql/mutations/send-email-to-friend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
---
group: graphql
title: sendEmailToFriend mutation
---

Use the `sendEmailToFriend` mutation to allow Magento to send a message on behalf of a customer to the specified email addresses.

{:.bs-callout-info}
The **Stores** > **Configuration** > **Catalog** > **Email to a friend** > **Enabled** field must be set to **Yes** to implement this mutation.

## Syntax

`mutation: {sendEmailToFriend(input: SendEmailToFriendInput): {SendEmailToFriendOutput}}`

## Example usage

The following example sends a message to two friends.

**Request**

```graphql
mutation {
sendEmailToFriend(
input: {
product_id: 10
sender: {
name: "Veronica Cost"
email: "roni_cost@example.com"
message: "Sarah needs this! http://luma.example.com/savvy-shoulder-tote.html"
}
recipients: [
{ name: "Amie Franklin", email: "afranklin@example.com" }
{ name: "Tomoko", email: "tomoko@example.com" }
]
}
) {
sender {
name
email
}
recipients {
name
email
}
}
}
```

**Response**

```json
{
"data": {
"sendEmailToFriend": {
"sender": {
"name": "Veronica Cost",
"email": "roni_cost@example.com",
},
"recipients": [
{
"name": "Amie Franklin",
"email": "afranklin@example.com"
},
{
"name": "Tomoko",
"email": "tomoko@example.com"
}
]
}
}
}
```

## Input attributes

The `SendEmailToFriendInput` object contains the following attributes:

Attribute | Data Type | Description
--- | --- | ---
`product_id` | Int! | The ID of the product that the customer is referencing
`recipients` | [SendEmailToFriendRecipientInput]! | An array containing information about each recipient
`sender` | SendEmailToFriendSenderInput! | Information about the customer and the content of the message

### SendEmailToFriendRecipientInput object {#SendEmailToFriendRecipientInput}

The `SendEmailToFriendRecipientInput` object must contain the following attributes:

Attribute | Data Type | Description
--- | --- | ---
`email` | String! | The email address of the recipient
`name` | String! | The name of the recipient

### SendEmailToFriendSenderInput object {#SendEmailToFriendSenderInput}

The `SendEmailToFriendSenderInput` object must contain the following attributes:

Attribute | Data Type | Description
--- | --- | ---
`email` | String! | The email address of the sender
`message` | String! | The text of the message to be sent
`name` | String! | The name of the sender

## Output attributes

The `SendEmailToFriendOutput` object contains the following attributes:

Attribute | Data Type | Description
--- | --- | ---
`recipients` | [SendEmailToFriendRecipient] | An array containing information about each recipient
`sender` | SendEmailToFriendSender | Information about the customer and the content of the message

### SendEmailToFriendRecipient object

The `SendEmailToFriendRecipientInput` object can contain the following attributes:

Attribute | Data Type | Description
--- | --- | ---
`email` | String | The email address of the recipient
`name` | String | The name of the recipient

### SendEmailToFriendSender object

The `SendEmailToFriendSender` object can contain the following attributes:

Attribute | Data Type | Description
--- | --- | ---
`email` | String | The email address of the sender
`message` | String | The text of the message
`name` | String | The name of the sender