Asked  7 Months ago    Answers:  5   Viewed   62 times

I'm building a fairly simple PHP script that will need to send some emails with attachments. I've found these 2 libraries to do this.

Does either one have significant advantages over the other? Or should I just pick one at random and be done with it?



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

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.

Wednesday, March 31, 2021
answered 7 Months ago

This is a well-known problem: GoDaddy does not allow outbound SMTP; you must relay through thir servers. This is covered in the PHPMailer troubleshooting guide, the principles of which still apply to SwiftMailer.

Wednesday, March 31, 2021
answered 7 Months ago

It's because of your SMTP server. Not the server that runs PHP. The SMTP server is blocked by the destination mail server. For making sure of it, if you change your settings (in PHP code) with Gmail server, it won't go to the spam folder any more.

It worked pretty well for a few months, but now the emails started to appear in a Spam folder for some of my customers?

That's because the destination mail server has added your SMTP server to their blacklist.

Saturday, May 29, 2021
answered 5 Months ago

I've used PHPMailer for my projects and have no complaints about it. Haven't used Swiftmailer, but both seem to be pretty much the same in terms of usage and usefulness, differing only in implementation details. When you get right down to it, they're both just friendly interfaces to hide the details of SMTP email from you.

Pick whichever one whose style suits you best and go with it.

Saturday, May 29, 2021
answered 5 Months ago

There's an addStringAttachment() method that seems to fit your need:


addStringAttachment(string $string, string $filename, string $encoding = self::ENCODING_BASE64, string $type = '', string $disposition = 'attachment') : boolean

Add a string or binary attachment (non-filesystem).

This method can be used to attach ascii or binary data, such as a BLOB record from a database.

Saturday, May 29, 2021
answered 5 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :