Email delivery

Delivery of email messages in MV is produced by Swift Mailer. By default, delivery of emails goes through mail function, it is possible to set up delivery through SMTP. In the core folder there is a file of "email.class.php" class where the class and "send()" method of e-mail delivery are defined.

Email :: send($recipient, $subject, $message[, $headers]);
 
Email :: send("test@domain.com", "Good news", "Text of good news");
 
$recipients = array("test@domain.com", "test-2@domain.com", "test-3@domain.com");
$recipients = implode(",", $recipients);
$message = "Long text of good news ...";
Email :: send($recipients, "Good news",  $message);

$headers = array("From" => "info@mysite.com");
Email :: send($recipients, "Good news", "Text of good news", $headers);

Signatures and e-mail formatting

To create a signature for all e-mails to be sent, go to "config/settings.php" file, there is an option "EmailSignature" which is added to the end of each e-mail (provided that the option is in the file and it is not empty). You are free to edit this signature the way you want. It also contains {domain} variable which is automatically replaced with the value of the "DomainName" option from the "config/setup.php" file.

Templates and CSS styles for emails are located in "customs/emais/default.php" file. You can change the template to the new one with a method of Email :: setTemplate("template_name"). File with a name "template_name.php" should be placed into "customs/emails/" folder.

Attention! When making the body of e-mail with use of HTML tags avoid using nested constructions, use simple methods as shown in the example below.

<p>Dear, John</p>
<p>Your order was successfully received and processed.</p>
<p>You can track your order in your <a href="http://domain.com/client/">private room</a> on our website.</p>
<p>Order details</p> 
<ul> 
   <li>Product 1, $40.</li> 
   <li>Product 2, $20.</li> 
   <li>Product 3, $60.</li> 
</ul>

Important notes

  1. Emails are sent in "utf-8" encoding.
  2. The subject of e-mail is also encoded in "utf-8".
  3. E-mail body type is "text/html" format.
  4. Additional headers can be passed in the optional parameter of $headers in the form of an associative array.
  5. Sender's address is specified in the "config/setup.php" file by "EmailFrom" parameter. The value should look like "John Johnson < ... >", and also it can be changed when passing an additional parameter of "$headers" which itself may contain additional titles.
  6. To see error logs of Swift Mailer when sending emails set the "Mode" parameter in "config/setup.php" to "development".