Skip to content

Instantly share code, notes, and snippets.

@sokratisg
sokratisg / Postfix: sender-dependent SASL authentication.md
Created April 24, 2017 10:35 — forked from zmwangx/Postfix: sender-dependent SASL authentication.md
Postfix: sender-dependent SASL authentication — relay to multiple SMTP hosts, or relay to the same host but authenticate as different users (e.g., two Gmail accounts)

This is a sequel to "Postfix: relay to authenticated SMTP".

I would like to send mail from two different Gmail accounts using Postfix. Here is the relevant section in the Postfix documentation: Configuring Sender-Dependent SASL authentication.

As a concrete example, here's how to set up two Gmail accounts (only relevant sections of the config files are listed below):

/etc/postfix/main.cf:
    # sender-dependent sasl authentication
    smtp_sender_dependent_authentication = yes

sender_dependent_relayhost_maps = hash:/etc/postfix/sender_relay

description "uWSGI application server in Emperor mode"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
setuid bots
setgid www-data
exec /usr/local/bin/uwsgi --emperor --emperor-nofollow /etc/uwsgi/apps
[uwsgi]
project = matterllo
base = /home/bots
chdir = %(base)/%(project)
home = %(base)/pyenv/%(project)
module=run:app
die-on-term = true
master = true
processes = 1
threads = 2
@sokratisg
sokratisg / wp_update_content.sql
Created May 24, 2015 21:52
WP convert http to https
UPDATE wp_posts
SET post_content = ( Replace (post_content, 'src="http://', 'src="//') )
WHERE Instr(post_content, 'jpeg') > 0
OR Instr(post_content, 'jpg') > 0
OR Instr(post_content, 'gif') > 0
OR Instr(post_content, 'png') > 0;
UPDATE wp_posts
SET post_content = ( Replace (post_content, "src='http://", "src='//") )
WHERE Instr(post_content, 'jpeg') > 0
@sokratisg
sokratisg / es_idx_replication.sh
Created April 8, 2015 14:31
Shell oneliner to update replicas of all elasticsearch indices
for i in `curl -XGET http://localhost:9200/_cat/indices | awk '{print $3}'`; do echo "curl -XPUT 'localhost:9200/$i/_settings' -d '{\"index\":{\"number_of_replicas\":1}}'"; done
---
148:
- 4
- :nf_f_conn_id
8:
- 4
- :nf_f_src_addr_ipv4
7:
- 2
- :nf_f_src_port
@sokratisg
sokratisg / technicolor_telnetlib.py
Created January 24, 2015 20:02
Technicolor telnetlib example
#!/usr/bin/env python
#
import telnetlib
import sys
max_wait = 2
prompt = "=>"
tn = telnetlib.Telnet("192.168.1.254","23")
tn.read_until("Username : ", max_wait)
@sokratisg
sokratisg / lircd.conf
Created January 11, 2015 19:03
Supertel Pilot TV Code 396 (Sony)
# Please make this file available to others
# by sending it to <lirc@bartelmus.de>
#
# this config file was automatically generated
# using lirc-0.9.0-pre1(default) on Sun Jan 11 20:58:28 2015
#
# contributed by
#
# brand: /home/pi/lircd.conf
# model no. of remote control:
@sokratisg
sokratisg / grok_tester.rb
Created November 17, 2014 14:38
grok tester
#!/usr/bin/env ruby
require 'rubygems'
require 'grok-pure'
require 'pp'
grok = Grok.new
grok.add_patterns_from_file("grok-patterns")
pattern = 'your_grok_pattern'
@sokratisg
sokratisg / vimrc
Created September 13, 2014 22:15
vim-enhanced configuration
" All system-wide defaults are set in $VIMRUNTIME/debian.vim (usually just
" /usr/share/vim/vimcurrent/debian.vim) and sourced by the call to :runtime
" you can find below. If you wish to change any of those settings, you should
" do it in this file (/etc/vim/vimrc), since debian.vim will be overwritten
" everytime an upgrade of the vim packages is performed. It is recommended to
" make changes after sourcing debian.vim since it alters the value of the
" 'compatible' option.
" This line should not be removed as it ensures that various options are
" properly set to work with the Vim-related packages available in Debian.