Simple SSH login email notify

Wanted to track remote SSH port forward login and the following is a great solution

$ cat /etc/profile.d/
if [ -n "$SSH_CLIENT" ]; then
TEXT="$(date): ssh login to ${USER}@$(hostnamectl –static)"
TEXT="$TEXT from $(echo $SSH_CLIENT|awk '{print $1}')"
echo $TEXT|mail -s "ssh login"

view raw
hosted with ❤ by GitHub


Change locale for WooCommerce email

To change WooCommerce email language you need to change the locale after order submit.

Using $_GET might be dirty, but works 🙂

* Plugin Name: Slovak WooCommerce emails
* Plugin URI:
* Description: Send only slovak WooCommerce emails
* Version: 1.0.0
* Author: Michal Zuber
* Author URI:
if (!defined('ABSPATH')) {
exit; // Exit if accessed directly.
add_filter('plugin_locale', 'custom_locale', 10, 2);
function custom_locale($locale, $domain)
if ('woocommerce' == $domain && isset($_GET['wc-ajax']) && $_GET['wc-ajax'] == 'checkout') {
return 'sk_SK';
return $locale;

WooCommerce email with custom total row

To add a custom total row to woocommerce email total section just hook into woocommerce_get_order_item_totals

Customise order total rows

add_filter('woocommerce_get_order_item_totals', 'my_woocommerce_get_order_item_totals', 10, 2);
function my_woocommerce_get_order_item_totals($total_rows, $order)
    $new_total_rows['cart_subtotal'] = $total_rows['cart_subtotal'];

    $new_total_rows['shipping'] = array(
        'label' => 'Slovak Parcel Service:',
        'value' => wc_price(3),

    $gateway = wc_get_payment_gateway_by_order($order);
    if ('cod' == $gateway->id) {
        $new_total_rows['cod'] = array(
            'label' => 'Cash on delivery:',
            'value' => wc_price(1),

    $new_total_rows['order_total'] = $total_rows['order_total'];

    return $new_total_rows;

Customizing Monolog HTML formatter for email

Monolog can send emails when there’s an error, but in the provided HTML formatter I missed the REQUEST_URI and REMOTE_ADDR that triggered the error.

Some info is in the exceptions section, but not always and needs horizontal scrolling in the email client 🙂

So I just replicated the HtmlFormatter and added some lines (dirty hacks).

Added service class

 <service id="app.monolog.formatter.html" class="App\Service\MonologEmailFormatter" public="false" />

Change formatter service ID

# app/config/config_prod.yml
    type: swift_mailer
    from_email: ""
    to_email: [""]
    subject: 'Error'
    level: error
    formatter: custom.monolog.formatter.html
    content_type: text/html

UPDATE: You might be interested in