Difference between revisions of "Injecting incoming email"

From Dreamwidth Notes
Jump to: navigation, search
m
(Notes on doing post/comment emails and support emails.)
Line 23: Line 23:
 
* Make sure that posting by email is enabled at http://www.yourname.hack.dreamwidth.net/manage/settings/?cat=mobile, with a permitted sender and a PIN. Make sure that your <tt>From:</tt> header is the permitted sender, and that the PIN is featured in one of the allowed places. Unless you are testing what happens when it isn't ;-)
 
* Make sure that posting by email is enabled at http://www.yourname.hack.dreamwidth.net/manage/settings/?cat=mobile, with a permitted sender and a PIN. Make sure that your <tt>From:</tt> header is the permitted sender, and that the PIN is featured in one of the allowed places. Unless you are testing what happens when it isn't ;-)
 
* Make sure that your successive test emails do not have the same date. There's some code intended to do rate-limiting that will drop successive emails that have less than five minutes between their <tt>Date:</tt> headers. This may not matter if you are restarting the worker each time - I haven't checked.
 
* Make sure that your successive test emails do not have the same date. There's some code intended to do rate-limiting that will drop successive emails that have less than five minutes between their <tt>Date:</tt> headers. This may not matter if you are restarting the worker each time - I haven't checked.
 +
* If you want to make a post or comment by email, be aware that in the default configuration, free users are unable to do this. You will need to either use http://www.yourname.hack.dreamwidth.net/admin/pay/ to give yourself a different account type, or edit the <code>%CAP</code> hash in the <code>$LJHOME/etc/config.pl</code> file to set the <code>emailpost</code> capability to 1 for free users.
 +
* If you're wanting to inject email intended for the support board, you'll need to make sure that the address you use in the "To" (or "Cc") header is defined as the reply address for one of the support categories. You can do this by going to http://www.yourname.hack.dreamwidth.net/admin/supportcat/ (giving yourself the '''supportadmin:support''' [[privs|priv]] if necessary), editing the category, and entering a valid email address into the "Reply address" field.
 
* For some maybe-useful diagnostics, try logging into your hack's System account and looking at http://www.yourname.hack.dreamwidth.net/admin/theschwartz
 
* For some maybe-useful diagnostics, try logging into your hack's System account and looking at http://www.yourname.hack.dreamwidth.net/admin/theschwartz

Revision as of 15:03, 16 June 2016

This page describes how to make a Dreamwidth install think it is receiving incoming email without actually sending it email. This might be useful if you are testing features such as post-by-email in an environment that is not able to receive email - such as a Dreamhack.

First, prepare the email. The easiest way is to send an email to yourself from one account to another and save the resulting message, including all headers, and then edit what you need to edit. In some clients this will be via a "view source" or "view original" link, or similar. Note that sending mail from one gmail account to another does not provide all the headers that you need - the email needs to actually go out to the internet and back. In particular, anything without Return-path: will be dropped as spam.

Make sure that your email does not have any blank lines anywhere until the body. This includes blank lines before the start of the headers. If you did accidentally leave a blank line at the top and not notice, you might spend two and a half hours wondering why nothing worked. Ahem.

Anyway, save your email somewhere accessible from the Dreamwidth installation. I'll assume from here that it's in your home directory and that it's called email.txt.

Incoming email is processed by the incoming-email worker. Start this with

$LJHOME/bin/worker/incoming-email

on a spare terminal. This will run until stopped by Ctrl-C, without showing any output on the screen.

Then, using another terminal, you can inject your test message by

$LJHOME/bin/incoming-mail-inject.pl < ~/email.txt

Hopefully, everything worked! If you are debugging something in the email-handling code, remember that you will need to restart the incoming-email worker after you change things to make sure that it is running the latest code.

Things to check if your emails are not doing anything useful:

  • Make sure that posting by email is enabled at http://www.yourname.hack.dreamwidth.net/manage/settings/?cat=mobile, with a permitted sender and a PIN. Make sure that your From: header is the permitted sender, and that the PIN is featured in one of the allowed places. Unless you are testing what happens when it isn't ;-)
  • Make sure that your successive test emails do not have the same date. There's some code intended to do rate-limiting that will drop successive emails that have less than five minutes between their Date: headers. This may not matter if you are restarting the worker each time - I haven't checked.
  • If you want to make a post or comment by email, be aware that in the default configuration, free users are unable to do this. You will need to either use http://www.yourname.hack.dreamwidth.net/admin/pay/ to give yourself a different account type, or edit the %CAP hash in the $LJHOME/etc/config.pl file to set the emailpost capability to 1 for free users.
  • If you're wanting to inject email intended for the support board, you'll need to make sure that the address you use in the "To" (or "Cc") header is defined as the reply address for one of the support categories. You can do this by going to http://www.yourname.hack.dreamwidth.net/admin/supportcat/ (giving yourself the supportadmin:support priv if necessary), editing the category, and entering a valid email address into the "Reply address" field.
  • For some maybe-useful diagnostics, try logging into your hack's System account and looking at http://www.yourname.hack.dreamwidth.net/admin/theschwartz