Categories
Linux Server Administration Tips

SMTP server telnet connection refused on Linux?

I was testing the WP Mail SMTP plugin to send emails in WordPress via SMTP servers but when it was trying to connect to the remote SMTP server, it kept getting error “Connection refused”.

So I tried:

telnet smtp.xxxx.com 587

To test the connection. Turned out my own server is preventing the outgoing request because of the permission denied error by CSF as I didn’t have enough privilege as an ordinary user of the server:

grep -i smtp_block /path/to/csf.conf

grep: /path/to/csf.conf: Permission denied

Needless to say, the telnet connection successfully went through to the remote SMTP server when I logged in as root.

So the solution is simple. Just add the user to /path/to/csf.conf for SMTP privilege:

SMTP_ALLOWGROUP = "mail,mailman,youruser"

That’s it. Now youruser is capable of connecting to remote SMTP servers.

Categories
Microsoft Windows Web Applications & Online Software

Office365 SMTP Send Emails as Shared Mailbox via smtp.office365.com

Go to Office.com admin center > Users > Active users.

Create a standalone user for the purpose of SMTP authentication, e.g. [email protected] with password XXYYZZ112233, as you don’t want to give the password of your existing users to apps (e.g. WordPress) that need to access your SMTP.

Edit the created account enabling SMTP authentication by Mail tab > Email apps > Manage email apps > Check “Authenticated SMTP” > Save changes.

SMTP account done.

Now, create a shared mailbox in Office 365 for the app to send email AS.

Go to Office.com admin center > Teams & groups > Shared mailboxes, and create a shared mailbox for your app, e.g. [email protected], with the newly created SMTP user as a member of it.

Wait 10 minutes or so for Office 365 to take this into effect so your new SMTP user [email protected] becomes a member of the shared mailbox [email protected].

Finally, you can use these as your SMTP details for your new app:

  • SMTP Host: smtp.office365.com
  • Encryption: TLS
  • Port: 587
  • SMTP Username: [email protected]
  • SMTP Password: XXYYZZ112233

And make sure to use the shared mailbox as From Email when you are sending, or Office 365 SMTP server will reject your request:

That’s it.

Categories
Programming Tips & Insights SQL / MySQL Tips and Tutorials

When to use NoSQL (e.g. MongoDB) and when to use SQL (e.g. MySQL)?

NoSQL is mostly about document databases while SQL is about relational databases.

  1. NoSQL vs. SQL
  2. Documents vs. Tables
  3. MongoDB vs. MySQL
  4. Property vs. Entity

The trick is 4: Property vs. Entity

Design your data models on a piece of paper.

Use MongoDB if …

If you see more trivial *entities* such as category, tag, brand, origin, etc. that are actually properties, go with NoSQL databases such as MongoDB because these are properties of documents. What you are trying to store is some kind of documents of these properties.

Use MySQL if …

If you see more real entities such as business, person, product, event, etc., go with a relational database such as MySQL because these are entities that should get tables on their own. What you are trying to store is a network of related entities.

Conclusion

Go with the solution that mandates the LEAST tables or document types so the structure is as simple as possible.

If you find the data structure becoming increasingly complex and difficult to maintain, you are probably using the wrong database technology.