Skip to main content

Posts

Sending Emails via SMTP

msmtp  requires a minimal setup for sending emails via SMTP compared to sendmail. Here is a configuration for you to send emails from a web host to an external SMTP server. Prior to doing that, you must check whether there is a clear communication channel between your web host and the SMTP server. You can use Telnet . Set up msmtp You are going to set msmtp as an MTA . Hence, you need to remove all other MTAs such as postfix and sendmail: $ sudo apt-get --purge autoremove postfix sendmail Install msmtp and related utilities: $ sudo apt-get install msmtp msmtp-mta mailutils Configure msmtp: $ sudo nano /etc/msmtprc # Set default values for all following accounts. defaults # Use the mail submission port 587 instead of the SMTP port 25. port 587 # Always use TLS. tls on # Set a list of trusted CAs for TLS. The default is to use system settings, but # you can select your own file. tls_trust_file /etc/ssl/certs/ca-certificates.crt # The SMTP server account mx host mail.mx.example
Recent posts

Sending SMTP Email via Telnet

You want your webhost to be able to send emails through an external SMTP server. The first thing to do is to check whether your webhost provider allows this to happen. Some concerned providers block outgoing SMTP ports to prevent you from doing email spamming. Let's try to connect with the SMTP server via Telnet from within your webhost. You may need to SSH into your webhost first. And then issue the following command: $ telnet -4 mail.example.com 587 The above command will connect to the mail.example.com SMTP server via port 587 and force Telnet to use IPv4. If the connection fails then your webhost provider may have blocked the outgoing SMTP port 587. You may need to politely ask your webhost provider to open the port for you. You can't do it yourself. Note: Telnet will resolve to IPv6 by default. If the SMTP port is not open on IPv6 then Telnet will appear hung until all trials via IPv6 connections are timed out. If IPv6 failed then it will resolve to IPv4.  Telnet should h

JQuery-UI Viewfinder

Users want to select a rectangular area. There are many ways to do it but we are going to use JQuery-UI . We will create a transparent JQuery-UI dialog box which users can drag and resize like a viewfinder. Around the dialog box's empty and see-through content area we will attach a rectangular frame which will resize as the dialog box resizes. We will measure the frame while a user is viewfinding a rectangular area with it. Here is the trick to make a JQuery-UI dialog box transparent. There is a dialogClass property which we can use to assign customized CSS classes to a JQuery-UI dialog box. We just need to add a class that set the background color with a transparent alpha value. Not the entire dialog box will be transparent but the content area will. That is just perfect for a viewfinder. We create a rectangular frame as a viewfinder using a div with a solid border, which we also set to resize itself whenever the dialog box resizes. We capture the current size and position of

The Software Stack for The Arduino CNC Controller

  Computer Numerical Control ( CNC ) is very much software driven. Yet, the architecture of the CNC software is obscured from the general software world. It has evolved separately with its own paradigm and nomenclature. At the heart of a CNC is the G-Code which is an old programming language that resembles an assembly language . A G-Code keyword is a combination of a letter and digits such as G0, G2, M2, M30, etc. All letters in the alphabet are fully used in G-Code. It is all about moving a tool onto a certain path in a work coordinate system with certain speed, duration, distance, and anything related to it. They call it jogging  and inching the tool. It may involves multiple tools simultaneously. The tools need to move accordingly to make, to assemble or to move products. Understanding how G-Code works is the precursor to understand how CNC works. In a CNC controller as depicted above, the Arduino Nano becomes the G-Code interpreter to control 3 stepper motors simultaneously. G-Co

Get Current User of Drupal 9 Externally

You have a stand-alone application that is not a Drupal module but resides in a Drupal sub-folder . And you want Drupal to manage your users. You want to access the currently logged-in Drupal user from your application. The following function will give you the current  user id, name, email and roles: use Drupal\Core\DrupalKernel; use Symfony\Component\HttpFoundation\Request; /** * Get Drupal current session user details. * Passing Drupal folder, or its relative folder such as '..' * when it is called from a Drupal sub-folder. * Return ['id', 'name', 'email', 'roles'] */ function get_drupal_current_user($drupal_dir) { // Change the directory to the Drupal root. chdir($drupal_dir); $drupal_root = getcwd(); if ($drupal_root === false) return []; $autoloader = require_once 'autoload.php'; $kernel = new DrupalKernel('prod', $autoloader); $request = Request::createFromGlobals(); // Emulate Drupal /index.php to get

How to Create a Tiny Gnome Panel Application

On every  Gnome Shell desktop there is a main panel at the top of the screen. Usually, the panel shows the current time, the WiFi signal, the speaker volume, the power button, and the activity startup button. There can be many other things on the panel as individual user penchants. The panel will not be covered by anything, and will be there at all time except when there is a full-screen application running. The Gnome community has decided that the whole humanity needs the panel. What little things of texts and icons on the panel are called Gnome Shell extensions. Each of them is a kind of a desktop application which always run through out a user session. They can be personalized. We are going to create a simple and useless application that shows a running counter, something like the one that shows '1473' on the panel image above. It can be a starting point for a bigger and productive application. But before we begin let's get familiar with a collection of handy Gnome too

fatal: Couldn't find remote ref master

If you are using Github then  master is now known as main . Whatever you want to do with a master must now be referred to a main . If you search for this error message on the Internet then you will encounter with a lot of old discussions on how to set up your master properly which is probably not what you are looking for. The master  is your problem. Rename it to main . I wrote Git My Way about two years ago. Today I created another Github repository. I got this  "fatal: Couldn't find remote ref master"  error message when I wanted to sync the new repo for the first time with my notebook using the notes I wrote in the blog. All the discussions around the error message I found on the Internet were perplexing. Then I recalled that Github had renamed master to main  due to the master-slave connotation. We always have a master copy of a code, never a slave copy. Now suddenly a word context has been diminished for good. What is going to happen to the existing vast documen