# simple PHP mail()

**URL:** <https://discourse.slimframework.com/t/simple-php-mail/2665>\
**Category:** Questions\
**Created:** [September 11, 2018, 8:06pm UTC](https://discourse.slimframework.com/t/simple-php-mail/2665 "2018-09-11T20:06:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![EugeneM](https://avatars.discourse-cdn.com/v4/letter/e/3be4f8/32.png) [@EugeneM](https://discourse.slimframework.com/u/EugeneM)\
**Post date:** [September 11, 2018, 8:06pm UTC](https://discourse.slimframework.com/t/simple-php-mail/2665/1 "2018-09-11T20:06:52Z")

</div>

The task is: from Android app via Retrofit 2 send some data of a contact form (name, email, phone number, subject of a message and the message itself) to email of recipient. It’s look like callback form. BUT, hoster of the recipient does’t recommend use PHPmailer and etc. It insists to use PHP mail(). The question: how to solve such problem with Slim 3? Thanks, in advance.

---

<div class="post-metadata">

**Author:** ![odan](https://avatars.discourse-cdn.com/v4/letter/o/9de053/32.png) [@odan](https://discourse.slimframework.com/u/odan)\
**Post date:** [September 13, 2018, 12:41pm UTC](https://discourse.slimframework.com/t/simple-php-mail/2665/2 "2018-09-13T12:41:12Z")

</div>

IMHO the PHP `mail()` function is the most dangerous solution for sending emails. Sending emails from PHP with SMTP, SSL and TLS support via `mail()` is even more difficult and dangerous. As far a I know Slim doesn’t recommend a “best practice” here because it’s not responsible for sending mails etc. Personally I like [zend-mail](https://zendframework.github.io/zend-mail/message/intro/) and [Swiftmailer](https://swiftmailer.symfony.com/).

---

<div class="post-metadata">

**Author:** ![EugeneM](https://avatars.discourse-cdn.com/v4/letter/e/3be4f8/32.png) [@EugeneM](https://discourse.slimframework.com/u/EugeneM)\
**Post date:** [September 13, 2018, 12:58pm UTC](https://discourse.slimframework.com/t/simple-php-mail/2665/3 "2018-09-13T12:58:47Z")

</div>

Thank you for your answer. But, it was said by hoster. If I understood everything right. Could you tell why you prefer Swiftmailer instead of PHPmailer? Thank you in advance

---

<div class="post-metadata">

**Author:** ![odan](https://avatars.discourse-cdn.com/v4/letter/o/9de053/32.png) [@odan](https://discourse.slimframework.com/u/odan)\
**Post date:** [September 14, 2018, 9:57am UTC](https://discourse.slimframework.com/t/simple-php-mail/2665/4 "2018-09-14T09:57:10Z")

</div>

This is just a matter of taste. PHPmailer with this mix of setters and public properties is not very “consistent” to me. There are also some security issues in PHPmailer, but they fix it very quickly. Swiftmailer is a little bit slow and don’t make use of namespaces. I also don’t like classes with underscores in my code base. The most modern and fasted email library seems to be zend-mail. That’s why I moved in the last years from mail() to PHPmailer to Swiftmailer and now to zend-mail.

---

<div class="post-metadata">

**Author:** ![EugeneM](https://avatars.discourse-cdn.com/v4/letter/e/3be4f8/32.png) [@EugeneM](https://discourse.slimframework.com/u/EugeneM)\
**Post date:** [September 14, 2018, 10:32am UTC](https://discourse.slimframework.com/t/simple-php-mail/2665/5 "2018-09-14T10:32:07Z")

</div>

Thank you, Daniel, for your prompt and clear answer.  
As I can see it’s case of taste and it depends.  
I’m mostly indie Android developer. But sometimes I need to jump into back-end technologies to make some APIs for Android apps. I’ve to take into account battery life during app’s work with server.  
Slim PHP framework is good for me as sufficient instrument for that.  
And … I follow your blog 😉  
Thank you once more.
