simple PHP mail()


#1

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.


#2

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 and Swiftmailer.


#3

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


#4

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.


#5

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 :wink:
Thank you once more.