That's okay demyr. I'll keep looking. I rather not install a third party library if I don't have to for two simple reasons.
I found that (when not sending via smtp) the build in Email class of CI4 is much simpler than PHPMailer (in the past I used PHPMailer and later SwiftMailer). And the documentation seems to indicate that it should be possible with the build in Email class. So why install an third party library then?
Second reason is that webspace is at a premium right now. Sure, PHPMailer doesnt take up a lot of space. But every little bit helps. We are a small non profit foundation that was established this february. So funds are low the first year. We hope to get our own server within the coming two years and be able to host our own website. Right now we have to make use of shared hosting with limited storage. And since we will be using a lot of e-mail we just have to make smart use of the webspace.
But if I can't get smtp to work with the build in Email class of CI4, I probably will be looking into using PHPMailer (or SwiftMailer, which I am more familiar with).
I must say that adding an attachment to the mail I send with the build in class was really easy. All I had to do was add this line:
$this->_email->attach($filename);
But thanks for your insight! I'll keep it in mind if I can't get smtp to work. But I'm starting to think it might actually be a server issue instead of a code issue. Our website was migrated to a different shared server last week. On the old server smtp worked fine.