Should I use php mail function or phpmailer?

后端 未结 1 809
难免孤独
难免孤独 2020-12-19 05:34

Well, so far, I have been using php built in function, mail(), and I have no problems with it, even I sent a blast to 1000+ users. But then, lately I found this phpmailer, w

相关标签:
1条回答
  • 2020-12-19 06:33

    Q1: You should definitely switch away from using mail()

    Q2: mail() function is really, really for simple stuff. Mail libraries hide a lot of low level stuff from the user, and offer simple ways to make HTML emails, embedded images in mail, etc.

    Instead of phpmailer I'd recommend SwiftMailer

    • Send emails using SMTP, sendmail, postfix or a custom Transport implementation of your own
    • Support servers that require username & password and/or encryption
    • Protect from header injection attacks without stripping request data content
    • Send MIME compliant HTML/multipart emails
    • Use event-driven plugins to customize the library
    • Handle large attachments and inline/embedded images with low memory use

    I've used SwiftMailer to send 15000+ mails, but as you'll find in SwiftMailer documentation, its recommended to send mails in smaller batches (depends on you server ex. 100, 200, 500 per batch), using cron.

    0 讨论(0)
提交回复
热议问题