Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create mail.md #152

Merged
merged 1 commit into from
Oct 19, 2018
Merged
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
44 changes: 44 additions & 0 deletions src/content/1.7/development/mail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
title: Register a new hook
PaoloFalomo marked this conversation as resolved.
Show resolved Hide resolved
weight: 70
---

# How to send e-mails

## Using the `Mail::send()` method

{{% notice note %}}
The `Mail` core class extends [`ObjectModel`][objectmodel]
{{% /notice %}}

{{% notice note %}}
This example is assuming you are using in a controller named `mycontroller` of a module named `mymodule`
{{% /notice %}}

```php
class mymodulemycontrollerModuleFrontController extends ModuleFrontController
{

public function initContent()
{
parent::initContent();
Mail::Send(
(int)(Configuration::get('PS_LANG_DEFAULT')), // defaut language id
'contact', // email template file to be use
' Module Installation', // email subject
array(
'{email}' => Configuration::get('PS_SHOP_EMAIL'), // sender email address
'{message}' => 'Hello world' // email content
),
Configuration::get('PS_SHOP_EMAIL'), // receiver email address
NULL, //receiver name
NULL, //from email address
NULL //from name
);
}
}
```

{{% notice tip %}}
Prestashop will use the Shop Configuration to decide if use `smtp` connection or php `mail` function so check it out on backoffice or in `app/config/parameter.php`
{{% /notice %}}