Using MailDir as a Backend for Gnus - emacs

I am using offlineimap to sync my gmail account to a locak maildir, then using gnus to read that directory everything is fine but gnus uses its own flags for marking read unread status of messages and they are not synced back to gmail. is there a way to force gnus to use standart maildir flags?

I use offlineimap and dovecot to download and serve my mail locally. I also use GNUS. Getting dovecot to work kept me from using GNUS for quite a while since GNUS's support for maildir is so lousy. This is what I needed to make dovecot work:
mail_location = maildir:~/Mail:LAYOUT=fs:INBOX=~/Mail/INBOX
One of the really nice parts of my solution is that I have a real and working offline sync, so that when the network is unavailable (approximate 80% of the time while on campus) I still can check and sort my mail.

This has been fixed in nnmaildir in Gnus trunk as of 2012-09-05. The fix appeared in the Gnus version released with Emacs 24.3.

A solution is to use a local imap server (as dovecot) to look at your maildir, and to use gnus to access to this imap server.

AFAIK, the situation has not improved about nnmaildir and gnus since this.
For this exact situation, I'm now using mutt, setting Emacs as its editor.

Here is everything the official manual has to say about maildirs and GNUS - I personally couldn't find there what you're looking for, but then again I'm a mew user, maybe you'll notice something I didn't. I hear, though, that Wanderlust has the best maildir support of all the Emacs mail readers.

Related

three ways to let PHP and a regular user edit the same files

I am a web developer, and for some upcoming projects I would like to use a file-based CMS. This means that many of the files I create at the start must be editable by the PHP user later, but also remain editable for my user (and also the other way around). My PC runs Debian 9, which I love but am not super knowledgeable about, and I have also just set up a local network server with Debian 9 for backups and possibly file sharing. (I'm using Webmin to configure this, which reflects my level of command line skills).
On my online shared hosting server, the PHP user and the FTP user seem to be the same, and 644/755 permissions work fine, this is also recommended by the CMS I'm using. I would like to mimic this on my computer so I don't have to fiddle with permissions all the time. But how do I do this? Currently, my regular user (anna) does not have access to www-data's files and vice versa. Putting them in the same group still means changing file permissions. Making anna the PHP user is a Bad Idea (as far as I understand it) because anna has sudo permissions.
So far I have researched three possible solutions that I don't really know very much about, and I would like to know which is the best route to take.
Develop locally on my computer and use apache-mpm-itk or suPHP to let PHP edit the files (I got that idea from this question on ServerFault).
Develop locally on my computer and rsync the files to my server with grunt-rsync, and somehow get rsync to set the ownership to www-data (another ServerFault thread helping here).
Mount the project's server directory, which is owned by www-data, on my computer with SSHFS and then either edit the files on the server directly or copy them over from my local directory with grunt-copy.
What do you think: from a security and ease of use perspective, which is the best way? Or do you know an even better one?
Thank you for taking the time to read and think about this!
Anna~
I figured it out! I finally ended up reading about running PHP as CGI instead of as an Apache module, and that this would solve my permissions problem. Plus, as far as I understand it, there are no extra security precautions to take when I'm the only one working with it on my local computer.
In case someone comes across this who might find it helpful, here's what I did (basically following these instructions):
I installed php7.0-fpm
Edited /etc/apache2/sites-enabled/000-default.conf and put the following just before </VirtualHost>:
DirectoryIndex index.php
<LocationMatch "^(.*\.php)$">
ProxyPass fcgi://127.0.0.1:9000/var/www/html
</LocationMatch>
I activated the Apache module proxy_fcgi (via Webmin, which apparently does an automatic Apache restart)
In /etc/php/7.0/fpm/pool.d/www.conf I commented out a listen line and put another below like this:
; listen = /run/php/php7.0-fpm.sock
listen = 127.0.0.1:9000
I then restarted PHP-FPM with this command: /etc/init.d/php7.0-fpm restart (a little different from the instructions, I'm on Debian 9). After that, phpinfo() gave me the Server API "FPM/FastCGI".
And finally, I changed the user and group from www-data to anna in three places, twice in /etc/php/7.0/fpm/pool.d/www.conf and then once more in /usr/lib/tmpfiles.d/php7.0-fpm.conf (this last bit may be Ubuntu/Debian specific, my thanks go to Keith for a comment on StackExchange).
And that was it! :-)

duplicate imap uid validities with mbsync

I am using mbsync to get imap mail from my university server and then dovecot locally to serve it to gnus/emacs. This works fine on one desktop machine, and one laptop, but a second laptop creates duplicate UIDs everytime I use it to access my mail. As I have the exact same set-up (to the best of my knowledge) on all three machines I am a bit baffled as to the source of this error. Does this ring any bells for anyone? Is there some sort of hidden or temp file that might be the source of such a problem that I could look for? Any guidance is appreciated.
mbsync version = 1.2.0
emacs = 24.5.50.1
dovecot 2.2.18
gnus 5.13
P.S. A great guide to fix these problems once they occur is this blog post here: http://tiborsimko.org/mbsync-duplicate-uid.html

I cannot send mail with SwiftMailer or PHPMailer from Localhost using gmail

I have recently been unable to send out mails through php on localhost. I use PHPMailer and SwiftMailer in different parts of the application.
With SwiftMailer I get this:
Connection could not be established with host smtp.gmail.com [ #0]
With PHPMailer, the message is:
SMTP Error: Could not connect to SMTP host.
My settings on SwiftMailer look like this:
$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, 'ssl')
->setUsername(APP_GMAIL_EMAIL)
->setPassword(APP_GMAIL_PWD);
I have gone through several threads here at SO and elsewhere, and tried many 'fixes' but the error messages remain the same. Some "solutions" I've tried are:
Enable OpenSSL inphp.ini (It was previously off)
Change smtp.gmail.com to smtp.googlemail.com
Replace smtp.gmail.com with certain gmail IP addresses
Replace smtp.gmail.com with gethostbyname('smtp.gmail.com')
Add ->setSourceIp('0.0.0.0') to the instantiation code above, after setUsername and setPassword
This code was previously working, and I'm not sure what could have broken the function. As part of troubleshooting, I have just confirmed that a similar code on Linux shared hosting is emailing satisfactorily, suggesting that the problem is somehow from my environment. Thus, I even tried different sources of internet access, in case it's an ISP thing.
How can I crack this nut?
I have been able to overcome the problem, at least with SwiftMailer. The solution must have arisen after my PHP upgrade from 5.2.5 to 5.6, which is the version I have currently. The insight came from this page:
https://github.com/swiftmailer/swiftmailer/issues/544
If you are using PHP 5.6, the error does occur because of the "SSL
context options" used for the stream context in swiftmailer. IN PHP
5.6 verify_peer and verify_peer_name the default was set to TRUE, so PHP checks the SSL certificate. It is currently not possible to
disable it in swiftmailer using some options.
You could disable the SSL check by modifying the function
"_establishSocketConnection" in StreamBuffer.php. Add these lines
before stream_socket_client command:
$options['ssl']['verify_peer'] = FALSE;
$options['ssl']['verify_peer_name'] = FALSE;
It would be great if these options could be set without hacking the
code.
Thanks to https://stackoverflow.com/a/29448735/2554788 who first pointed me to the said post.
By the way, the path to StreamBuffer.php is:
\lib\classes\Swift\Transport
A word of warning though: this solution is based on hacking the code inside a class, and will probably fail, say, after upgrading SwiftMailer versions (in which case you'd need to go back and hack the code again).
Perhaps, more current versions of SwiftMailer have put their acts together in PHP 5.6 (I use SwiftMailer 5.1 currently). I intend to try an upgrade ASAP, hoping there has been an elegant fix for this issue.

PHP mail() in dev environment: open the mail in a browser/editor instead of sending it?

On my machine I need to test the mails sent by my application. I'd rather avoid sending real mails.
Is there a way to have the email content showed to the screen a way or another, maybe by opening it in gedit or any text editor?
Maybe like replacing the commandline used to launch "sendmail"?
I am asking for Linux machines (Ubuntu more specifically).
Include a means of determining your environment in your project, or at least some kind of global variable that holds that information.
Then build an abstract mail interface that either sends real mails if it's running on a production server, but logs them to local files in case it runs on a dev machine / environment. As a logging package, I would recommend Monolog.
This would allow you to design the rest of your application (or at least the mail sending components) in a way that doesn't have to care about the environment.
After searching, here is the solution I came to:
create a script that will fake a smtp server
/usr/local/bin/sendmail-fake:
#!/bin/bash
{
date
echo $#
cat
} >> /var/log/sendmail-fake.log
configure PHP:
php.ini:
sendmail_path = /usr/local/bin/sendmail-fake
In this setup, emails are logged into a file. The script could be modified to open the content into a browser.
More details on the blog post.

Configuring Gmail in gnus in Aquamacs

I'm a new emacs user, and I'm trying to get gnus working with mi gmail account with Aquamacs.
So far, I've been able to set it up to receive my mail. The problem is when I try to send an e-mail. I get this error:
No Gnus is good news
No more unread newsgroups
Mark set
Sending...
Sending via mail...
No STARTTLS program was available (tried 'gnutls-cli')
ad-Orig-error: Sending failed; SMTP protocol error
I understand that 'gnutls-cli' is necessary, and that it is not included in Aquamacs. I've found this guide to install it http://www.gnu.org/s/gnutls/manual/gnutls.html, but I'm not sure how I have to proceed, since I'm using MacOs and not Linux (although both are UNIX OS)
My question is: what do I exactly have to do to be able to send emails?
You could install opensll and configure Gnus to use it instead of
gnus-tls.
From the Gnus Manual:
`nntp-open-ssl-stream'
Opens a connection to a server over a "secure" channel. To use
this you must have OpenSSL (http://www.openssl.org) or SSLeay
(ftp://ftp.psy.uq.oz.au/pub/Crypto/SSL) installed. You then
define a server as follows:
;; "snews" is port 563 and is predefined in our `/etc/services'
;; however, `openssl s_client -port' doesn't like named ports.
;;
(nntp "snews.bar.com"
(nntp-open-connection-function nntp-open-ssl-stream)
(nntp-port-number 563)
(nntp-address "snews.bar.com"))