 Let's just start. OK, guys, talk about sending email from PHP. Hopefully, I mean, I have that problem. I guess all of you will probably have that problem sooner or later. So hopefully, I'm not giving you what you should do. I'm actually, this is me crying for help because I'm actually not too sure how to do it myself. And I'm just going to show you what I've done and where I'm at. And hopefully, you guys can chime in to say how you solve your email problem or something like that. And don't suggest something else besides email because that would be crazy. Soon as someone says telegram or WhatsApp or something else besides email, you'll lose me. You'll lose me. So yeah, email. So the big problem with email is to send transactional emails. Who knows what transactional emails are? Come on, you know. Come on. Come on. Oh, that person over there. Almost. I just made it up because there's no camera back there. Password reset and stuff. What? Password reset. Password reset. Yeah. Is marketing email transactional? Yes, it could be. If it's like an online signup form that you said, OK, view this page and they have to put them in their email and then you send them an email with a link to them. I guess marketing is quite broad, isn't it? So nowadays I think it's fair to say that you need to have transactional emails to tell people their lost passwords, to tell people to come back to your site, to tell you. I mean, I use email a lot to tell me when there's a new signup or someone's done a particular action on the system. I think it's easier than logs for some reason because logs are so boring that I just ignore them. But email is a little bit more high level for me. So yeah, I rely on emails to do my business. And most web applications do use emails, I hope. But the problem is to send, nowadays, is to send emails so that you know that the person received it. Like, if you send an email to reset a password or give someone a password and it's not being sent, that's kind of a problem. And another problem, especially with PHP, as I've found, is that when using the default mail thing, it can be a bit slow. So these are my problems. Try to send it reliably, try to send it fast. So I mean, once upon a time, people just used like a LAMP stack and PostFix. And PostFix kind of solves the sending the email fast in the sense that it's queued in PostFix. But then again, running PostFix nowadays is like just a nightmare. I actually still do it. And I hate every day that goes by maintaining that PostFix. Well, I don't really do it every day. It's just like, I'm trying not to look at it. I'm trying not to look at the logs. I'm trying not to understand what's going on, because it will hurt me. It will hurt my brain. So does anyone run their own mail server? Who's dumb enough to do that? OK. Well, it's actually quite, when it's working, it's quite nice. But when there's problems with it, it can be a nightmare. And I don't really, if you're a company, I've been running my company since 2007. So I've had a mail server since 2007. Hence, my domain, webconverter.com, is quite reputable. But if you're starting a new company doing some stupid, what is the start-ups doing nowadays? Something crazy, like loyalty programs or getting your money back somehow. Or if you start up a new Singaporean company, Fubada SG, and you don't have a reputation, you might find it very difficult to get your emails delivered. And also, I was just going to bemoan the LAMP stack and PostFix weren't really simple at all, actually. And the new way of doing things with Docker is a lot better. Yeah, so I also was going to bemoan that transactional email, like for example, my email host, I actually host my email with Fastmail. I used to use Gmail, but then I got some sense and used something else, because putting all your eggs in one basket is kind of crazy. But I think this is the case with Gmail. Fastmail certainly don't allow transactional email. And Fastmail, I don't know what Fastmail don't allow, but do Gmail allow transactional email? Maybe they don't, maybe they do, who cares? But some hosts do, don't or whatever. So sometimes sending transactional mail through your existing host might be not a feasible option. And then also, I wanted to bemoan, who uses PHP Mail? It's very limited, actually, and it sucks a bit. You can't do attachments. You can't use PHP Mailer. Well, this one, that thing. Mail function. Oh, my internet just died. OK, who cares? OK, so what are the solutions? Let's use a third party. Some go over there, said customers, something. I mean, everyone uses some third party, don't you? Which third parties do you guys use? Send pulse. Send pulse? Yeah, most third party services you should pay for, I guess. Otherwise, they're probably, I mean, the trouble I have with all these third parties is it's quite difficult to compare. There's so many nuances. There probably is one that offers it for free, but then they'll put an advertisement in your email footer, and that would be nuts, wouldn't it? Anyone else use a third party email sender thing? Mail gun. That's a good one. I mean, I've heard of that one. Send grid. And also, those third party ones, I think send grid, they have more built-up APIs. So you can do feedback loops and have callbacks. And they have a particular use case kind of catered for. But nonetheless, I was hoping you guys would just recommend something over another and give me some inspiration. But you don't have to say now, I guess. Just let me know at some point. Because I am having a difficulty comparing them more and finding which one I like. So ultimately, I just ended up using AWS, because everyone else does that, and it's quite cheap. I did write up a guide how to use it on my slides. And my slides will be available with a video, I guess. But nonetheless, that's the third party. It's like getting your stuff to the mailer and such things. That was another problem in itself. Maybe I'm not the biggest PHP expert in the world, but I found it a challenge to send email quickly, asynchronously, with PHP. I posted a question on Stack Overflow. Here's a tip for you. If you don't know what you're doing, post a question on Stack Overflow. I wouldn't be a programmer today if it wasn't for that site. If that site went down, I would have to quit being a programmer, because Stack Overflow is everything. So I posted a question like, how do you do this asynchronously? Because PHP is slow if it's doing some synchronous thing that takes a long time, like delivering an email. So which one of these do you think would solve the problems? Anyone got a clue how to make something asynchronous in PHP? Come on. What do you think it is? Second last one. Oh, that's cheating. Oh, that happens. OK, anything else? But the problem with exec, though, is that say you have a complicated email that you want to get from your PHP into exec, that you have to pass in somehow, the argument, I mean, unless I'm mistaken, getting arguments into exec is a huge pain in the butt. So it's got some serious drawbacks. Well, on the Stack Overflow question, people registered, and you're like, oh, you're an idiot. You should be using threads, dude, and threads, you can do it. And I actually spent a whole lot of time implementing this threads thing, and it doesn't work. And then some people had the balls to recommend me bean stalk. Oh, yeah, yeah, yeah. Your simple solution is not going to work. You should deploy a million lines of code and this new queuing system. And then you can get it working. Like, no, I'm not deploying a million lines of code, you moron. So then other people recommended me PHP and Swift. They also don't solve the problem. And registered shutdown function, it looked promising. I was like, oh, yeah, this is going to do it. No, it doesn't do it. The one that does work is fast CGI finish request. To my surprise, it works. But I don't know if you're crazy like me, but I like to run PHP scripts from the command line to see if they work and all that sort of stuff. Of course, that function doesn't work from the command line. So that sucks. So I'm actually still not entirely sure how to make something asynchronous in PHP, besides using exec. And come on, exec is super duper duper duper lame. There's got to be a better way than this. There's got to be a better way. I guess you have multiple computers, you know. No. No. We're not doing that. You suck, pal. Anyway, so basically, I'm being a bit of a PHP stalwart. I've been hanging on. All these new languages have come around. Ruby, Golang, Shell, now that Microsoft has got it. And you can do cool things in these languages. But PHP, it's really difficult to do something quite as simple like this. Even the exec stuff is a disaster. So what is my current solution? Oh my god. My current solution, the fastest way I've actually managed to do it is to not actually use SMTP. Because when I was measuring sending email through SMTP, it was slow. It was like taking more than three seconds per email. The fastest way to do it is actually to use Amazon's Curl API, or is it what you call it? Or what do you call it? RESTful API? What is the term for these things? RESTful. RESTful. RESTful. The fastest way to do it is actually just to do a web request to SCS. And that's really sad, because the server isn't bloody Oregon. But anyway, it's the fastest way I've found how to send lots of email through a web request. But that's actually pretty cool, because we're doing web applications. In SMTP, this is probably something that we could live without. So yeah, doing it by web request is quite cool. And I'm using a library called PHP-AW-SES. Never mind that. And then this is, oh, you can't really see the bottom of my slide. But this is, why is this so small? And you'd be wondering how I get asynchronous in my app nowadays. And this is how I do it. I make the email call actually in the browser. I don't do it in the back end. You're probably thinking, this guy's an idiot. But no, it actually works really well. Unless the browser, what do you call it, a surfer? Is that what you call a client nowadays? I'm not down with a lingo. A user. I mean, the trouble is that even though this is like 1.5 seconds, what can happen is that the surfer, it's got to be a better name for this. The surfer can just close the browser or navigate away. And of course, the email won't get sent. Or it can be interrupted, maybe. So that's how I do asynchronous stuff. Isn't that super duper lame just to do it in the browser? No, no, well, I'm not spamming people. I'm just getting the surfers, the clients, to just let me know what they're up to by sending me email. So that's how I'm doing it right now. I'm not using SMTP. I'm not using any crazy language features. I'm using curl. And I'm using the browser to send email. Oh my gosh. And then the next thing I wanted to be able to do is just setting up AWS, SES. I don't know. Who's done that before? Who set up AWS, SES? Did you feel like your life was pretty losing time? I thought I was. Because verifying emails, verifying domains, getting it all set up, it's quite a pain, I found. And then ultimately, you're left with the same boring questions, like if you use AWS, do you actually monitor the bounces? Do you monitor the deliverability and all the rest of it, the statistics that come back? Supposedly. That means no. But yeah. So you can't see all these statistics, but they're so boring that you just almost don't want to even look at them. So yeah, I have a problem now still. I think the emails are getting through, but I'm actually not even doing all the checks to make sure that's even happening. And I was actually curious to know how people solve that. I think SendGrid have a very sexy user interface that makes you want to log in and check their stats. But I've never used it. But I know Amazon SES doesn't want to, I don't want to log into AWS console because it's really boring and slow. It feels like swimming in molasses or something. So yeah, that's my talk. It's just gave you problem after problem and how I didn't solve it. Yep. Well done. Have you tried using Revit? Oh, for Christ's sake. This is like the beanstalk argument. OK, yeah, yeah, yeah, yeah, go on. Revit MQ plus? Plus the PHP meal function. Because PHP itself, there's a library for you to do interaction with Revit MQ as well. Well, it's just a queue, like I guess beanstalkers, even though I don't even know what beanstalk is. I'm imagining a big beanstalk with green beans and it's long. And it's probably like a queue. Because didn't the giant come down after him? So did the giant come down before him? No, it's a queue, as I'm thinking. Revit MQ, I'm thinking Revit's. I have no idea what MQ stands for, mail queue. It's just a queue. So it's just another queue. But I don't want to use a queue. I don't want to use a queue. I think that's a bit lame. Have you looked at the QMN? Do you know what QMN is? Is that the thing that gives browsers extra powers? Is that a guy who sells drugs? QMN lets you set up like a time server, time relationship. You have workers, and you have which can take some requests and push it up to different QMN instances. Sounds complicated. You don't like frameworks. No, I like things being simple. I just want to call a mail function and it to be fast. But to be honest, I'm not actually that bothered about how slow it is now because I do it in the browser. And my real problem is just the monitoring, all that stuff. I don't know how to actually check that everything's really actually awesome. Last question. We moved off SES. What? Too cheap? No. None of our emails were getting accepted by Hotmail. What? Who cares about Hotmail? They're all old people. Everyone else is buying Hotmail. Most of our clients are old people. What are you building? Pensioners. Pensioners.sg. To your parents. What? To your parents with teenage kids. Well, those are old people. So they're old people. Have you got teenage kids? No. So yeah, so none of our emails were going to Hotmail. And we had no visibility of this sort of thing. And then even once we realized that that was happening. Well, Amazon usually send statistics like if it got how many deliveries, how many bounces, if it got accepted. So to go back to your first point, how do you monitor this stuff? Well, you can monitor it. But I mean, the problem is that you get the stats, but no one looks at them. So now you get like a report from your customer.io saying, oh, Mr. Person in Hotmail didn't get your email or something. No, we've had fewer people calling up and claiming they haven't received email. Well, that's not the greatest monitoring technique I've ever heard of. It's like, no one's complaining. Awesome. That's the exact rate. Dan, has anyone got a crazy email story? Because that one was pretty crazy. What are you using? Is it customer.io? Did I get that one? Customer.io. So you basically send off a QR request saying that a user has clicked on the bathroom and not done something. And then you set up all the emails on there. And they fire off based on the events you send them. So all of these messages are forward off. So it takes like 0.01 seconds to do anything. And then they do all the monitoring. OK. I do see the value of third parties. Actually, if anything, I'm here to say, who has the best third party solution here? Use use one. Well, what about you, the swagger guy? What do you use? I basically use a mail gun. So all I can say is the mail does get delivered into the inbox and not the trash. And that's all you care about? Yeah, I mean, there's as much as you can hope for. And is there some nice stats to show your boss or something? No. Basically, you just want to guarantee that it gets there? They guarantee that? Well, for the most part, after we test between various mail providers, it does go with you. You really do test? Or you just, like, not really? So much. OK. Yeah. I think that's my talk, guys. Yeah. Thank you, guys. Any questions? Let me know. Oh, yeah, here's all my details. I'm actually, my wife told me to say this. I'm looking for work. No, because I need to get my income up. So if anyone needs a PHP person who doesn't really know what he's doing, actually, I know my way around PHP. I just don't use object-oriented PHP. Who uses object-oriented PHP? Who's that PHP 7 guy? It's you, isn't it? Yeah. Well, I do have applications I do all this stuff, too. That kind of stuff. So yeah, thanks, guys, for running my evening.