Where are received mails by Mailcatcher stored? - mailcatcher

I have installed postfix on my Mac with and changed the following parameters :
mydestination =
relayhost = 127.0.0.1:1025
I've modified mydestination to be blank so that whoever the mail is sent to like bellow in the Terminal it necessarily goes through the relayhost (even if it's sent to #localhost) and I can see it appear in my web-browser in Mailcatcher's tab :
echo "Body test" | mail -s "Subject test" test#dev.local
But here's the thing, when I receive the mail I do receive it instantly with the built-in websockets but if I do reload the page localhost:1080, emails are still there, meaning they must be stored somewhere.
After searching I found that the following URL redirects to a .json that contains received mails that are print out in Mailcatcher's tab :
localhost:1080/messages
But if I do a ls -l in my webroot directory, there's no messages.json that appears. And when you do click on the "Quit" button in Mailcatcher's, then relaunch it by doing mailcatcher and opening again localhost:1080 mails have disappeared...
I don't understand, is there a file that is deleted when you do click "Quit" and that I might haven't seen ?
Thanks for your help !

If you check the source on GitHub you will find something like this SQLite3::Database.new(":memory:", :type_translation => true).tap do |db| in mail.rb.
You may not have noticed, but MailCatcher uses SQLite, and the above tells you that it is configured to run in memory. So, when turning off MailCatcher all the rows that are contained in this database are lost.

Related

Sending both a body and attachment using mail (Linux)

I want to send an email from Linux with body and attachment. However, it only sends either one of the two. When I have both in the command, only the attachment is sent. I'm working with a log file as body and a CSV file as an attachment. I have tried the following;
mail -a "FROM: Name <name#email.com>" -s "subject of email" "recipient#email.com" -A /home/Export/attachment.csv <<< "$BODY_SUCCES"
For which the variable $BODY_SUCCESS is a log file. I have also tried making it work with mutt and mailx, but neither seemed to work, unfortunately. I can't figure out what's going wrong here. Can anyone help?

Why do Period will be ignored at the beginning of a sentence in SendEmail on Linux

I want to use command line to send an email on Linux so I choose sendEmail (a lightweight, command line SMTP email client). However, I find Period (.) at the beginning of a sentence will be ignored and it really confused me.
-m MESSAGE message body
My command:
sendEmail -f sender#example.com -t receiver#example.com -u "Test mail" -s smtp.example.com -xu sender#example.com -xp sender_password -m ".Hello\n..Hello\nHello.world" -o tls=no
What I want to display is:
.Hello
..Hello
Hello.world
But the result is:
Hello
.Hello
Hello.world
Thanks a million.
This is a bug in the sendEmail client. In SMTP a line containing nothing else but a single period . is used to indicate the end of the message (DATA segment in SMTP). To avoid unintended transmission termination if a message contains a line with a single period, on all lines starting with a period an extra period has to be added before the message goes onto the wire; and removed upon receive. It's the task of a proper SMTP client to take care of this. It's clearly a faulty behavior of the client.
To get around the bug, add an extra period.
For details see RFC5321, sections 4.1.1.4 and 4.5.4.

linux command - how to send a notification email using shell script to administrator

How can I send in Linux a notification email using shell script to administrator
about monitor a given sites/machines, given at runtime, and notifies an administrator by email if any of the sites/machines becomes unresponsive
send, in Linux, a notification email to administrator (I assume: local root account):
echo "simple ascii only message here" | mail -s "subject line" root
or
cat notification_file | mail -s "subject line" root
#note: notification_file's content will be the "body" of your email. Not an attachment.
#It should contain only regular ASCII characters... ie, basically:
# letters, numbers, punctuations, newlines, tabs, spaces.
#Anything else could be tricky. If you need more (unicode? attachments?),
#you should use a variant (ex: mutt ?) instead of the basic "mail" command
If you meant an outside mail, to a work/personnal email, you'll need to read a bit about how mail systems work, as by default it will not be able to reach the correct smtp server in the correct way...

Need to capture the commands fired on Linux

I would like to capture all the commands fired by a user in a session. This is needed for the purpose of auditing.
I used some thing like below,
LoggedIn=`date +"%B-%d-%Y-%M:%H"`
HostName=`hostname`
UNIX_USER=`who am i | cut -d " " -f 1`
echo " Please enter a Change Request Number for which you are looging in : "
read CR_NUMBER
FileName=$HostName-$LoggedIn-$CR_NUMBER-$UNIX_USER
script $FileName
I have put this snippet in .profile file, so that as soon as the user logs in to a SU account this creates the file. The plan is to push this file to a central repository where an auditor can look into those files.
But there are couple of problems in this.
The "script" command spools all the data from the session, for example say, a user cats a property file, It appends all the data of the property file to the auditing file.
Unless user fires the 'exit' command, the data will not be spooled to auditing file, by any chance if user logs out with out firing exit command, the auditing file will be empty.
Is there any better solution for auditing ? History file is not an option since it does not tell me for which Change Request number ( internal to my organisation) the commands are fired. Is there any other way just capture only the commands fired but not the output ?
Some of the previous discussion are here and here
I think this software exactly matches your need:
https://github.com/a2o/snoopy

OfflineIMAP and Mutt with Gmail's All Mail folder

OfflimeIMAP
I am trying to sync my Gmail - All Mail folder with idlefolders through offlineimap. My .offlineimaprc config has this -
idlefolders = ['INBOX', '[Gmail].All Mail']
My name of my All Mail folder in .mail (where my mailboxes are) looks like
drwx------ 5 ry ry 4096 Oct 12 18:13 [Gmail].All Mail
I think the name is wrong in idlefolders. I see a lot of people online using [Gmail]/All Mail.
My INBOX folder sync fine but All Mail does not.
MUTT
Also trying to set a macro shortcut to All Mail in .muttrc I have -
macro index ga "<change-folder> =[Gmail].All Mail<enter>"
This does not work, but my macro for INBOX does work
macro index gi "<change-folder> =INBOX<enter>"
What's wrong? How should I call my All Mail folder?
for my Mutt 1.5.21, percent encoding works:
macro index ga "<change-folder>=[Gmail]/All%20Mail<enter>"
I think the problem here is the whitespace in the folder. Possible solutions:
Update: As winchendonsprings pointed out, there is a way to escape the whitespace in the folder name. Now we can use a macro to change to All Mail:
bind editor <space> noop
macro index ga "<change-folder>=[Gmail].All Mail<enter>" "Go to all mail"
You use a name transalation to create mailboxes without a
whitespace as described in the
documentation.
For example the translation could look like this:
nametrans = lambda x: re.sub('\[|\]|\s', '_', x)
You should make sure, as the documentation states, that no folder
ends up with the same translated name. You can check this by running
offlineimap with --info.
Another possible solution could be, to register your mailboxes and
simply use a macro to toggle between the index and your list of configured
mailboxes, eg. in your .muttrc:
mailboxes =[Gmail].All\ Mail =[Gmail].Important =[Gmail].Starred
macro index <left> ':mailboxes <enter>c?<toggle-mailboxes>
That provides the benefit that mutt monitors your local mailbox and
tells you if you've got new mail. You can even automate this if you want. Examples can be found here.
Another terrible solution is to just use <complete> to avoid typing a literal space:
macro index ga "<change-folder>=[Gmail]/All<complete><enter>"

Resources