PhpMailer vs. SwiftMailer?

33

Solution 1

I was going to say that PHPMailer is no longer developed, and Swift Mailer is. But when I googled ...

https://github.com/PHPMailer/PHPMailer

That suggests its being worked on again.

I've used PHPMailer a lot, and its always been solid and reliable. I had recently started using Swift Mailer, for the above reason, and it too has given me no trouble.

Now that PHPMailer is developed again, I think I'll probably give the new version a try.

So, my answer is that both are capable, and that it doesn't matter that much – choose one, learn it, use it. Both offer massive advantages over mail() and abstract away the nuances of email so that you can get on with whatever you are really trying to develop.

Solution 2

Whatever the features are, they have variety in their applicable licenses:

PHPMailer - LGPL 2.1 (https://github.com/PHPMailer/PHPMailer)

SwiftMailer - MIT license (https://github.com/swiftmailer/swiftmailer)

Solution 3

There is also Zend_Mail. If I had to pick one for a new project today, I would seriously consider that.

Solution 4

Having looked at both I think SwiftMailer has a much nicer interface than PHPMailer and as someone has pointed out Zend_Mail is also another good option especially if you're using other Zend components. It makes life much easier if you use everything from the same framework.

Solution 5

I've used PHPMailer on many projects and never had a problem. It's feature complete and it has good docs.

I had never heard of Swiftmailer so I took a peek at the website. It seems a nice solution too.

If your needs are simple as you say, then just pick one at random.

Share:
33
JosephDoggie
Author by

JosephDoggie

Updated on July 08, 2022

Comments

  • JosephDoggie
    JosephDoggie almost 2 years

    I am working on a legacy .net version 1.0 aspx.cs project for web development.

    To debug the code, I use a series of Response.Write statements such as:

     string strMessage = "Reached start of method A";
     Response.Write("<script>alert('"+strMessage+"');</script>");
    

    These work; however, when I get to a new constructor:

     MyObject myObject1 = new MyObject();
    

    the message doesn't appear.

    It seems unlikely to me (for other reasons) that the constructor would fail here.

    Does anyone have any thoughts as to why the message doesn't appear?

    Could there be a memory issue?

    If I comment out the constructor, the next message does indeed appear.

    • Victor
      Victor almost 9 years
      can you give as smallest but complete example which we can reproduce
    • JosephDoggie
      JosephDoggie almost 9 years
      @Victor: That's a good thought, but IP rules forbid me to send the project, and making a "skinny" project is probably not in scope for me right now, but thanks -- I do appreciate it. Has anyone ever encountered similar behavior in a classic aspx.cs project before?
    • JosephDoggie
      JosephDoggie almost 9 years
      @Victor: Actually, this inspires me to make a empty class with constructor and see what happens ... it should be interesting to see whether it succeeds or fails .... results will be forthcoming!
    • JosephDoggie
      JosephDoggie almost 9 years
      @Victor: The empty-class constructor did indeed work; somewhat intriguing!
    • JosephDoggie
      JosephDoggie almost 9 years
      @Victor: your request inspired me to solve the problem, many thanks 1
  • Marco Demaio
    Marco Demaio over 12 years
    It doesn't seem you can use it on its own, I think you need to use the entire zend library which is more than 6 MB compressed in the minimal version.
  • Dracs
    Dracs almost 11 years
    PHPMailer has moved to GitHub now. New Link github.com/Synchro/PHPMailer
  • MaxiWheat
    MaxiWheat almost 10 years
    Zend_Mail works great, but yes, requiring the whole framework is kind of a dowside for small projects if you don't use Zend Framework.
  • M A Hossain Tonu
    M A Hossain Tonu almost 10 years
    May I know why I got a down vote? There are big differences in licensing when we want to use one of'em for our distributable project.
  • Steve Chambers
    Steve Chambers over 9 years
    This thread may also be useful: forums.phplist.com/viewtopic.php?t=8270
  • Steve Chambers
    Steve Chambers over 9 years
    IMO the anonymous down vote seems unfounded - this is a good point. But think the post would be more valuable if you could perhaps point out any important differences between the two licenses...?
  • M A Hossain Tonu
    M A Hossain Tonu over 9 years
    Someone's upvote clears that :) Anyway the major differences between the two licenses are as: LGPL is "infectuous", which means if you use it, you risk having to (L)GPL your own work too. GPL (and, depending on the circumstances, LGPL as well) practically excludes usage in a closed-source project. MIT is the "Can do Anything" license, do what you want with my code excepted pretend that the code is yours
  • Steve Chambers
    Steve Chambers over 9 years
    Very helpful - many thanks
  • Synchro
    Synchro about 9 years
    Most of the above PHPMailer links are obsolete - you should now start here.
  • Synchro
    Synchro about 9 years
    To be clear (I'm the maintainer), PHPMailer does now live on github at the address in this answer, not the old sourceforge, google code repos, or my personal fork (Synchro).
  • Marco Demaio
    Marco Demaio about 9 years
    @Synchro: I updated the links, next time feel free to edit my answer and fix it by yourself.
  • divix
    divix over 8 years
    ZF Mail doesn't require you whole of the 6mb framework. One of the best features of Zend Framework is that you can use only classes which you need. However you will still need like 10-20 files to include from Zend.
  • iquito
    iquito over 7 years
    The comment from M A Hossain Tonu about the LGPL being "infectuous" is completely wrong. The difference between GPL and LGPL is exactly that: GPL is a strong copyleft license, meaning all your code must be changed to a GPL-compatible license too, whereas LGPL only includes a copyleft part for the code in the distributed library, so not your application code. For a library like PHPMailer LGPL is completely fine and irrelevant to your own code, which is not affected at all by this license.
  • MrMesees
    MrMesees over 7 years
    > SwiftMailer is made by hundreds of small files that make SwiftMailer more difficult to debug compared to the 3 files PHPMailer is made of. Terrible reasoning. number of files should not be a deciding factor on using a library or debugging as debugging does not involve fiddling with files, it involves stepping through execution flow.
  • Marco Demaio
    Marco Demaio about 7 years
    @MrMesees: well stepping through execution flow by looking into hundreds of micro files is more time consuming than looking at few bigger files. :)
  • M A Hossain Tonu
    M A Hossain Tonu about 6 years
    Of course, LGPL is less restrictive than the GPL origins (also hinted in its name: Lesser GPL). While the GPL license requires you to share the code of all “derivative work”, the LGPL requires you to share only the source code of the work “based” on the LGPL-licenses components and not of the work which ‘uses’ it, meaning you are not obligated to share the code that is designed to work with the library by being complied or linked with it - static or dynamic.
  • M A Hossain Tonu
    M A Hossain Tonu about 6 years
    Hence, considering the derivative works from PHPMailer, “infectuous” word used to describe the point of sharing your code component if it is “based” on LGPL licensed components. In general purpose, you are not deriving work from PHPMailer, so it absolutely fine and take the license headache out.