Titre
Lien permanent
Contenu
| Old | New |
|---|
| 1 | | 1 | # Emails
|
|---|
| | 2 |
|
|---|
| | 3 | LiteCart has it's own mail composer.
|
|---|
| | 4 |
|
|---|
| | 5 | Outgoing emails are stored in the database table lc_emails for 30 days.
|
|---|
| | 6 |
|
|---|
| | 7 | ## Entity Controller
|
|---|
| | 8 |
|
|---|
| | 9 | Minimal example:
|
|---|
| | 10 |
|
|---|
| | 11 | ```php
|
|---|
| | 12 | $email = new ent_email();
|
|---|
| | 13 | $email->add_recipient('user@email.com', 'John Doe')
|
|---|
| | 14 | ->set_subject('This is a subject')
|
|---|
| | 15 | ->add_body('...')
|
|---|
| | 16 | ->send();
|
|---|
| | 17 | ```
|
|---|
| | 18 |
|
|---|
| | 19 | Full example:
|
|---|
| | 20 |
|
|---|
| | 21 | ```php
|
|---|
| | 22 | $email = new ent_email();
|
|---|
| | 23 | $email->set_sender('you@domain.tld', 'Store Name')
|
|---|
| | 24 | ->add_recipient('user@email.com', 'John Doe')
|
|---|
| | 25 | ->add_cc('user2@email.com', 'John Doe')
|
|---|
| | 26 | ->add_bcc('user3@email.com', 'John Doe')
|
|---|
| | 27 | ->set_subject('This is a subject')
|
|---|
| | 28 | ->add_body('...', true) // true for passing HTML content
|
|---|
| | 29 | ->add_attachment($file, $filename, false) // If first parameter is binary data and not a filename, third parameter should be set to true
|
|---|
| | 30 | ->send();
|
|---|
| | 31 | ```
|
|---|
| | 32 |
|
|---|
| | 33 | Save a draft:
|
|---|
| | 34 |
|
|---|
| | 35 | ```php
|
|---|
| | 36 | $email = new ent_email();
|
|---|
| | 37 | ...
|
|---|
| | 38 | $email->save();
|
|---|
| | 39 |
|
|---|
| | 40 | echo $email->data['id']; // Outputs email ID e.g. 123
|
|---|
| | 41 | ```
|
|---|
| | 42 |
|
|---|
| | 43 | Open and send a draft:
|
|---|
| | 44 |
|
|---|
| | 45 | ```php
|
|---|
| | 46 | $email = new ent_email(123);
|
|---|
| | 47 | $email->send();
|
|---|
| | 48 | ```
|
|---|
| | 49 |
|
|---|
| | 50 | ## See Also
|
|---|
| | 51 |
|
|---|
| | 52 | * [SMTP Client](smtp_client) |
|---|
Modifié par tim le 28 févr. 2024 à 23:49