<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>email &#8211; Luxing Huang</title>
	<atom:link href="https://luxing.im/tag/email/feed/" rel="self" type="application/rss+xml" />
	<link>https://luxing.im</link>
	<description>Thoughs and things</description>
	<lastBuildDate>Mon, 29 Jul 2019 15:04:05 +0000</lastBuildDate>
	<language>en-CA</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.2</generator>
<site xmlns="com-wordpress:feed-additions:1">58771605</site>	<item>
		<title>Make a secret copy of sent email in Postfix</title>
		<link>https://luxing.im/make-a-secret-copy-of-sent-email-in-postfix/</link>
					<comments>https://luxing.im/make-a-secret-copy-of-sent-email-in-postfix/#comments</comments>
		
		<dc:creator><![CDATA[Luxing Huang]]></dc:creator>
		<pubDate>Sat, 06 Aug 2016 13:53:01 +0000</pubDate>
				<category><![CDATA[Techie Stuff]]></category>
		<category><![CDATA[bcc]]></category>
		<category><![CDATA[copy]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[postfix]]></category>
		<guid isPermaLink="false">https://luxing.im/?p=682</guid>

					<description><![CDATA[I have a business need. I need to send automatically generated email from a specific business address to my customers. Postfix does not help you to save it to &#8220;Sent&#8221; mailbox. Although I have mail logs telling me that emails have been sent to the correct email addresses but I really don&#8217;t know what is &#8230; <p class="link-more"><a href="https://luxing.im/make-a-secret-copy-of-sent-email-in-postfix/" class="more-link">Continue reading<span class="screen-reader-text"> "Make a secret copy of sent email in Postfix"</span></a></p>]]></description>
										<content:encoded><![CDATA[<p>I have a business need. I need to send automatically generated email from a specific business address to my customers. Postfix does not help you to save it to &#8220;Sent&#8221; mailbox. Although I have mail logs telling me that emails have been sent to the correct email addresses but I really don&#8217;t know what is being sent.</p>
<p>Because I setup my own mail server, this is going to be really easy. There is no need to change my business code to BCC a secret address, which is not very nice.</p>
<p><span id="more-682"></span></p>
<p>The steps are simple.</p>
<p>Add the line to /etc/postfix/main.cf</p>
<pre>sender_bcc_maps = hash:/etc/postfix/sender_bcc</pre>
<p>Write your <code>sender_bcc</code> file</p>
<pre>
business@address.com  bcc@example.com
</pre>
<p>Generate the hash.</p>
<pre>cd /etc/postfix
postmap sender_bcc
</pre>
<p>This will generate a .db file.</p>
<p>Reload postfix</p>
<pre>postfix reload</pre>
<p>Then all your email sent from <code>business@address.com</code> will automatically bcc&#8217;d to <code>bcc@example.com</code>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://luxing.im/make-a-secret-copy-of-sent-email-in-postfix/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">682</post-id>	</item>
		<item>
		<title>Sending email with Python</title>
		<link>https://luxing.im/sending-email-with-python/</link>
					<comments>https://luxing.im/sending-email-with-python/#respond</comments>
		
		<dc:creator><![CDATA[Luxing Huang]]></dc:creator>
		<pubDate>Tue, 22 Mar 2016 19:41:37 +0000</pubDate>
				<category><![CDATA[Techie Stuff]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[smtplib]]></category>
		<category><![CDATA[tls]]></category>
		<guid isPermaLink="false">https://luxing.im/?p=629</guid>

					<description><![CDATA[This is a note from learning Python&#8217;s email and smtplib modules. Most of emails nowadays consists of 3 parts: plain text content, HTML content and attachments. Python&#8217;s smtplib library indeed saved us a lot of work. 1. Create a multipart/alternative email envelope. from email.mime.multipart import MIMEMultipart alter = MIMEMultipart('alternative') msg = MIMEMultipart() This will create &#8230; <p class="link-more"><a href="https://luxing.im/sending-email-with-python/" class="more-link">Continue reading<span class="screen-reader-text"> "Sending email with Python"</span></a></p>]]></description>
										<content:encoded><![CDATA[<p>This is a note from learning Python&#8217;s <code>email</code> and <code>smtplib</code> modules.<br />
Most of emails nowadays consists of 3 parts: plain text content, HTML content and attachments. Python&#8217;s <code>smtplib</code> library indeed saved us a lot of work.<br />
<span id="more-629"></span></p>
<p>1. Create a multipart/alternative email envelope.</p>
<pre>
from email.mime.multipart import MIMEMultipart
alter = MIMEMultipart('alternative')
msg = MIMEMultipart()
</pre>
<p>This will create an envelope that will contain all 3 mentioned parts. In mutt&#8217;s view:</p>
<pre>
1 <no description>                    [multipa/alternativ, 7bit, 16K] 
2 ├─><no description>                 [text/plain, base64, utf-8, 0.1K] 
3 ├─><no description>                 [text/html, base64, utf-8, 0.1K]  
4 ca.crt                              [applica/octet-stre, base64, 1.5K]
</pre>
<p>Some MIME type is truncated, but you get the idea.</p>
<p>2. Unicode<br />
You will have to append the coding part in the source file.</p>
<pre>
#!/usr/bin/python
# -*- coding: utf-8 -*-
</pre>
<p>The second line must exist.</p>
<p>Then a unicode title and text:</p>
<pre>
from email.mime.text import MIMEText

# msg and alter is derived from the previous example
msg['Subject'] = u'中文'
text = u'正在用Python写东西'
alter.attach(MIMEText(text, 'plain', 'utf-8'))

msg.attach(alter)
</pre>
<p>Appending HTML just change the <code>plain</code> to <code>html</code> when you call <code>MIMEText</code> against HTML content.</p>
<p>3. Add attachments<br />
Mind the relative / absolute path from the location you execute the script. It&#8217;s recommend to use absolute path.</p>
<pre>
from os.path import basename, dirname, realpath

# assuming I will attach all the files in the same location as the script itself, also a file from other relative path.
cwd = dirname(realpath(__file__))
files = ['myfile.bin', 'herfile.bin', '../other/dir/s.bin']

for f in files:
        # use absolute path
        with open(cwd + '/' + f, "rb") as fil:
            msg.attach(MIMEApplication(
                fil.read(),
                Content_Disposition='attachment; filename="%s"' % basename(f),
                Name=basename(f)
            ))
</pre>
<p>4. Message ID.<br />
Some SMTP server supports adding message id to your email on a specific port, e.g. 25. But when you use <code>starttls</code> to connect the SMTP or use a different port, e.g. 587, Message-Id may not be added automatically. So your email probably won&#8217;t be received as it&#8217;s required in <a href="https://tools.ietf.org/html/rfc2822.html" target="_blank">RFC 2822</a>.</p>
<p>One way to get around that is to generate your own message id. Then you could use <code>starttls()</code> to send your emails securely.</p>
<pre>
from email.utils import make_msgid

# Inherit the msg from above example.
msg['Message-Id'] = make_msgid('example.com')

smtp = smtplib.SMTP('smtp.example.com', 587)
smtp.starttls()
smtp.login('sender@example.com', 'emailpassword')
smtp.sendmail(sender, to, msg.as_string().encode('utf-8'))
smtp.quit()
</pre>
<p>Note that the message id it generated will use the host name of your current machine if you do not specify.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://luxing.im/sending-email-with-python/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">629</post-id>	</item>
		<item>
		<title>Email Notifier</title>
		<link>https://luxing.im/email-notifier/</link>
					<comments>https://luxing.im/email-notifier/#respond</comments>
		
		<dc:creator><![CDATA[Luxing Huang]]></dc:creator>
		<pubDate>Sat, 29 Mar 2014 15:30:58 +0000</pubDate>
				<category><![CDATA[Techie Stuff]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[notification]]></category>
		<guid isPermaLink="false">http://blog.luxing.im/?p=333</guid>

					<description><![CDATA[In the western world, email is a formal way of communication. It&#8217;s still widely used in a lot of fields. University usually send me on average 3 emails per day in weekdays, some days are considerably more. I don&#8217;t like keeping email clients open, it consumes my workspace and technically more memory space. I&#8217;d love &#8230; <p class="link-more"><a href="https://luxing.im/email-notifier/" class="more-link">Continue reading<span class="screen-reader-text"> "Email Notifier"</span></a></p>]]></description>
										<content:encoded><![CDATA[<p><img decoding="async" src="https://mergy.org/wp-content/uploads/email-icon.png" width="200" height="173" class="alignleft" />In the western world, email is a formal way of communication. It&#8217;s still widely used in a lot of fields. University usually send me on average 3 emails per day in weekdays, some days are considerably more.</p>
<p>I don&#8217;t like keeping email clients open, it consumes my workspace and technically more memory space. I&#8217;d love to take a desktop widget that tells me &#8220;you have a new mail&#8221;.<br />
<span id="more-333"></span><br />
Recently I came across an application called Mailnag, a python written programme which uses GTK3+ library (<a href="http://python-gtk-3-tutorial.readthedocs.org/en/latest/index.html" target="_blank">gi.repository</a>) to notify the user new emails. </p>
<p>Mailnag is intuitive to use and it must be working very well. I didn&#8217;t test it though. I personally don&#8217;t like GNOME 3 too much but I love the old GNOME 2. Is there a programme that we can use in GTK2?</p>
<p>Sure we do.</p>
<p>A programme called <em>mail-notification</em> pops up during my Google search. It is a little programme that only pops up if new email is received. The main Linux distributions should have it <a href="http://pkgs.org/search/?query=mail-notification&#038;type=smart" target="_blank">collected</a> in their repositories.</p>
<p>Configuration can be launched via System->Preference->Look and Feel in Fedora 20, you also need to add <em>mail-notification</em> to Startup Applications for automatic boot.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://luxing.im/email-notifier/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">333</post-id>	</item>
		<item>
		<title>Using Mutt as Email client</title>
		<link>https://luxing.im/using-mutt-as-email-client/</link>
					<comments>https://luxing.im/using-mutt-as-email-client/#comments</comments>
		
		<dc:creator><![CDATA[Luxing Huang]]></dc:creator>
		<pubDate>Fri, 04 Oct 2013 01:00:08 +0000</pubDate>
				<category><![CDATA[Techie Stuff]]></category>
		<category><![CDATA[client]]></category>
		<category><![CDATA[config]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mutt]]></category>
		<guid isPermaLink="false">http://blog.luxing.im/?p=15</guid>

					<description><![CDATA[I&#8217;ve always fascinated with my professor Jim Diamond&#8217;s email client, and how it interacts with his zsh. Start from today, I am going to change my main email client from Thunderbird to Mutt too. Here is a small piece of snippet that I put into my ~/.mutt configuration. You may follow my steps and copy &#8230; <p class="link-more"><a href="https://luxing.im/using-mutt-as-email-client/" class="more-link">Continue reading<span class="screen-reader-text"> "Using Mutt as Email client"</span></a></p>]]></description>
										<content:encoded><![CDATA[<p>I&#8217;ve always fascinated with my professor Jim Diamond&#8217;s email client, and how it interacts with his <em>zsh</em>. Start from today, I am going to change my main email client from Thunderbird to Mutt too. Here is a small piece of snippet that I put into my ~/.mutt configuration. You may follow my steps and copy the necessary information to your mutt configuration files.</p>
<p><span id="more-15"></span></p>
<p>It is nearly a year that I haven&#8217;t used Windows as my in-production OS, instead I&#8217;ve used either RedHat sponsored Linux distro (Fedora) or a RHEL-copy CentOS.</p>
<pre>sudo yum install mutt</pre>
<p>Now it is the fun part.</p>
<p>By default, your mutt will read info from ~/.muttrc or ~/.mutt/muttrc. Since I have several email addresses needed to be setup, I use the second one.</p>
<pre>mkdir -p ~/.muttrc/accounts</pre>
<p>Which creates requested folders.</p>
<p>Go to ~/.mutt/accounts/ and create your email account file (you may name it as your like, but keep track of the file name) like the following way:</p>
<pre># Uni Email Setting, file name: university
set from = "abcdef@esp.tld"
set realname = "Your Name Here"
# IMAP settings here
set imap_user = "abcdef"
set imap_pass = ""       # Password is empty here so you'll key-in passwords everytime you wish to access your email account
set folder = "imaps://imap.mail.tld:993"
set spoolfile = "imaps://imap.mail.tld:993/Inbox"   # For gmail users, you need to set your spoolfiles to "+INBOX"
set imap_check_subscribed
set mime_forward=yes
set mime_forward_rest=yes

#SMTP settings
set smtp_url = "smtp://abcdef@smtp.esp.tld:587/"
set smtp_pass = ""

set mail_check = 120
set timeout = 300
set imap_keepalive = 300
# You can set the postponed/record to "+Drafts" or "Sent" correspondently below.
set postponed = "imaps://imap.mail.tld:993/Inbox.Drafts"
set record = "imaps://imap.mail.tld:993/Inbox.Sent"
set header_cache=~/.mutt/cache/headers</pre>
<p>You can also put your GnuPG keys under your account if you have multiple keys for multiple emails for some reason. You need to copy the <a href="http://dev.mutt.org/trac/wiki/MuttGuide/UseGPG" target="_blank">content</a> over under each of your account setting. Remember to substitute your public key identifier in the config files.</p>
<p>You can create similar ones with gmail, assume that you have read the comments above.</p>
<p>Now we put some general information into our muttrc:</p>
<pre>vim ~/.mutt/muttrc</pre>
<pre>set editor = "vim"
set header_cache=~/.mutt/cache/headers
set message_cachedir=~/.mutt/cache/bodies
set certificate_file=~/.mutt/certificates
set move = no
set include
set sort = 'threads'
set sort_aux = 'reverse-last-date-received'
set auto_tag = yes
ignore "Authentication-Results:"
ignore "DomainKey-Signature:"
ignore "DKIM-Signature:"
alternative_order text/plain text/html *
auto_view text/html
bind editor  complete-query
bind editor ^T complete
bind editor  noop
set hostname = desktop.luxing.im
set sig_on_top = yes

# Create a statusbar shows the information in localtime.
set pager_format="%4C %Z %[!%b %e at %I:%M %p]  %.20n -- %s%* -- (%P)"

# Accounts and Shortcuts
source ~/.mutt/accounts/acadia
macro index <f2> '<sync-mailbox><enter-command>source ~/.mutt/accounts/yeah<enter><change-folder>!<enter>'
macro index <f3> '<sync-mailbox><enter-command>source ~/.mutt/accounts/126<enter><change-folder>!<enter>'


# move spam to Spam/ from: http://chrisjrob.com/2011/03/23/configuring-mutt-for-spam/
macro index S "<tag-prefix><enter-command>unset resolve<enter><tag-prefix>N<tag-prefix><enter-command>set resolve<enter><tag-prefix><save-message>=INBOX.Spam<enter>" "file as Spam"
macro pager S "<save-message>=INBOX.Spam<enter>" "file as Spam"

macro index H "<tag-prefix><enter-command>unset resolve<enter><tag-prefix>N<tag-prefix><enter-command>set resolve<enter><tag-prefix><save-message>=INBOX<enter>" "file as Ham"
macro pager H "<save-message>=INBOX<enter>" "file as Ham"

# return to inbox by pressing .
macro index . "<change-folder>=INBOX<enter>" "Inbox"

set pager_format="%4C %Z %[!%b %e at %I:%M %p]  %.20n  %s%* -- (%P)" # show the corresponding local time of the email.
set pgp_use_gpg_agent = yes

</pre>
<p>You need to adjust your accounts corresponding to your settings.</p>
<p>If you put sensitive information like your passwords into your <em>account</em>, remember to chmod 600 for security concern.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://luxing.im/using-mutt-as-email-client/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">15</post-id>	</item>
	</channel>
</rss>
