# Slim 2.\* and swiftmailer

**URL:** <https://discourse.slimframework.com/t/slim-2-and-swiftmailer/79>\
**Category:** Questions\
**Created:** [April 5, 2016, 8:25am UTC](https://discourse.slimframework.com/t/slim-2-and-swiftmailer/79 "2016-04-05T08:25:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dima85](https://avatars.discourse-cdn.com/v4/letter/d/eada6e/32.png) [@Dima85](https://discourse.slimframework.com/u/Dima85)\
**Post date:** [April 5, 2016, 8:25am UTC](https://discourse.slimframework.com/t/slim-2-and-swiftmailer/79/1 "2016-04-05T08:25:01Z")

</div>

I want to optimize the work with swiftmailer. Look it’s a good idea?

* * *

````auto
  require_once 'vendor/swiftmailer/swiftmailer/lib/swift_required.php';
  $transport = Swift_SmtpTransport::newInstance('host.com', 25);
  $mailer = Swift_Mailer::newInstance($transport);
  return $mailer;
};```

****

```$app->get("/send", function () use ($app,$database) {
      $mailer = $app->mailer;
      $html_body = 'News<br>'.htmlspecialchars($comment);
      $message = Swift_Message::newInstance('New')
        ->setFrom(array('noreply@host.com' => 'Notify'))
        ->setTo(array('host@host.com' => 'host'))
        ->setBody('News.')->addPart($html_body, 'text/html');
      $numSent = $mailer->send($message);
});```
````

---

<div class="post-metadata">

**Author:** ![akrabat](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/akrabat/32/9_2.png) [@akrabat](https://discourse.slimframework.com/u/akrabat)\
**Post date:** [April 5, 2016, 8:50pm UTC](https://discourse.slimframework.com/t/slim-2-and-swiftmailer/79/2 "2016-04-05T20:50:28Z")

</div>

Looks fine to me. 👍

---

<div class="post-metadata">

**Author:** ![Was\_tecno](https://avatars.discourse-cdn.com/v4/letter/w/3ec8ea/32.png) [@Was\_tecno](https://discourse.slimframework.com/u/Was_tecno)\
**Post date:** [May 30, 2017, 3:52pm UTC](https://discourse.slimframework.com/t/slim-2-and-swiftmailer/79/3 "2017-05-30T15:52:50Z")

</div>

Estou começando com Slim e gostaria de manda e-mail de uma que estou criando com Slim pode me Ajudar?
