I would like to store my incoming e-mails as *.msg files and i try this with the following external delivery method; This is working well but i receive the mail as one large plain text string.
foofoofoo unix - n n - - pipe
flags=F user=www-data argv=/mle/scripts/parse_postfix.sh ${sender} ${recipient}
My parse_postfix.sh contains the following code;
#!/bin/bash
mail=$(cat);
ddate=`date +%Y%m%d_%H%M%S`
msg_file=${ddate}.msg
path=/mle/spool/${code}
echo $mail > ${path}/${msg_file};
The output of this method is one large string and i can't read it with a MIME:Parser;
(example 1)
From foo#gmail.com Sat Aug 23 19:22:27 2014 Received: from mail-yh0-f49.google.com (mail-yh0-f49.google.com [209.85.213.49]) by foo.testtesttest.com (Postfix) with ESMTPS id D83DC43C8 for <foo#testtesttest.com>; Sat, 23 Aug 2014 19:22:26 +0000 (UTC) Received: by mail-yh0-f49.google.com with SMTP id b6so9924529yha.36 for <foo#testtesttest.com>;
The example mail listed below is the way how i can read it properly with the MIME:Parser;
(example 2)
Delivered-To: foo#testtesttest.com
Received: by 10.140.108.135 with SMTP id j7csp222526qgf;
Thu, 3 Jul 2014 06:26:51 -0700 (PDT)
X-Received: by 10.194.82.106 with SMTP id h10mr3033237wjy.115.1404394010626;
Thu, 03 Jul 2014 06:26:50 -0700 (PDT)
Return-Path: <foo#gmail.com>
Received: from mail-we0-x22c.google.com (mail-we0-x22c.google.com [2a00:1450:400c:c03::22c])
by mx.google.com with ESMTPS id e6si24028130wix.75.2014.07.03.06.26.50
for <foo#testtesttest.com>
(version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
Thu, 03 Jul 2014 06:26:50 -0700 (PDT)
Received-SPF: pass (google.com: domain of foo#gmail.com designates 2a00:1450:400c:c03::22c as permitted sender) client-ip=2a00:1450:400c:c03::22c;
What is the best way to convert the 1st example to the 2nd example? Or to save the e-mail properly like the 2nd example?
You are not quoting the variable properly.
echo "$mail"
The sane solution is to not use a variable at all, though.
ddate=$(date +%Y%m%d_%H%M%S)
msg_file=${ddate}.msg
path=/mle/spool/${code}
cat> ${path}/${msg_file}
This will still be problematic if there is more than one message arriving during the same second.
I cannot see why you are not using the built-in delivery mechanisms of Postfix itself, anyway. If you want more control over delivery, maybe hook in Procmail, which has a built-in delivery mode for running numbering of messages. Proper Maildir would still be better for most real-world scenarios, as it is more robust.
Related
I am using vue2-datepicker but i can't save date into database because the date format binded as Tue Jun 04 2019 00:00:00 GMT+0530 (India Standard Time)
How can i solve this?
my code is
<date-picker
type="date"
:lang="lang"
v-model="form.join_date"
>
</date-picker>
but console.log(this.form.join_date) is Tue Jun 04 2019 00:00:00 GMT+0530 (India Standard Time)
How can i get date like '2019-06-18'
Anyone can help me?
thanks in advance
There is an attribute called value-type that would let you bind a string with a specific format instead of a Date object. Based on their examples, I believe it would be something like this:
<date-picker
value-type="format"
format="YYYY-MM-dd"
:lang="lang"
v-model="stringValue">
</date-picker>
See here: https://github.com/mengxiong10/vue2-datepicker#value-type
I've set up the mail app and created a shell script to FTP to a website server and then send an email to the admin. Last night it was working perfectly. I made changes to it this morning and it started sending two of the same email with different ASCII characters within the subject line.
#Send an email confirming update
cat /Users/rmdlp/Documents/Scripts/message.txt | mail -s “Website Update” myemail#myemail.ca
Here is a snippet of the email subject I receive:
Everything else works fine. The "message.txt" file is within the body of the message and it gets to my email OK.
Also in the sender's list this string is being added:
I also receive a "You have mail in /var/mail/$USER", which I did not receive before. I looked at that file and this is a portion of what it outputs:
Diagnostic-Code: X-Postfix; unknown user: "update???"
--9490A103F482.1450820767/Roys-MBP.lan
Content-Description: Undelivered Message
Content-Type: message/rfc822
Return-Path: <rmdlp#Roys-MBP.lan>
Received: by Roys-MBP.lan (Postfix, from userid 501)
id 9490A103F482; Tue, 22 Dec 2015 16:46:05 -0500 (EST)
To: rmdlp#live.ca, Update”#Roys-MBP.lan
Subject: “Website
Message-Id: <20151222214605.9490A103F482#Roys-MBP.lan>
Date: Tue, 22 Dec 2015 16:46:05 -0500 (EST)
From: rmdlp#Roys-MBP.lan (Roy Perez)
The command mail -s “Website Update” is not doing what you think it does. “ is U+201C, LEFT DOUBLE QUOTATION MARK, which is not the same thing as ". Unlike ", “ is not treated specially by the shell, and so the command gets split up at the whitespace in Website Update, resulting in a subject of “Website and an extra recipient of Update”. This extra recipient is interpreted as Update”#<YOUR HOSTNAME>, but because there is no such user, the email to it gets bounced back and ends up in your mailbox. All the "unknown characters" along the way are due to encoding issues.
This is why you use plain text editors to write code, not word processors.
I am using git-bash on a Windows system.
The Windows clock shows local time, but inside git-bash everything is in GMT time:
$ date
Mon Mar 31 16:08:57 GMT 2014
Also setting TZ will not change things:
$ TZ="Europe/Berlin" date
Mon Mar 31 16:09:01 GMT 2014
Similarly all times it git log are GMT only.
Is there a way to set the correct timezone in git-bash?
On Windows the TZ variable seems to work differently.
To get the German timezone you have to write:
TZ=GST-1GDT date
If you set it to some "invalid" value like "Europe/Berlin" it will default to GMT.
The same seems to happen on my system when TZ is not set at all.
With the above setting I get Thu Apr 17 16:23:23 GDT 2014 which is not exactly the same as Thu Apr 17 16:23:23 CEST 2014, but at least the time looks right.
Same problem here in my script. Windows was showing 15:47 and the "date" command in gitbash was answering 13:47.
export TZ="CEST-2"
This fixed the problem for me. I wanted Paris time.
I'm wondering regarding the output of the following example:
when parsing 01/03, will it be resolved as Mar, 1st or Jan, 3rd?
Ruby is not locale dependent. Because Ruby is a server-side language and not a client-side language like JavaScript, Ruby uses the system clock from your web app server - and uses this information to calculate the time. Whatever timezone you have your system set to is what your Ruby app will use.
When parsing a date from a string, DateTime will make its best guess based on how the input is formatted:
DateTime.parse('01/03')
#=> Thu, 03 Jan 2019 00:00:00 +0000
DateTime.parse('2019/01/03')
#=> Thu, 03 Jan 2019 00:00:00 +0000
DateTime.parse('01/03/2019')
#=> Fri, 01 Mar 2019 00:00:00 +0000
You can also explicitly tell DateTime how you want your string parsed using strptime:
date = '01-03-2019'
DateTime.strptime(date, '%m-%d-%Y')
#=> Thu, 03 Jan 2019 00:00:00 +0000
DateTime.strptime(date, '%d-%m-%Y')
#=> Fri, 01 Mar 2019 00:00:00 +0000
I am using the ruby gem "Chronic" to parse four digit strings as DateTime objects. I am using time in military format (ie: "0800") which seems from the documentaion to be a valid format.
In most cases, Chronic parses time in this format correctly - however it always parses a four digit string beginning with "12" as 00:XX AM of the next day, never as 12:XX PM of the current day.
For example:
>> Chronic.parse("1234")
=> Thu Sep 17 00:34:00 -0600 2009
I see that if I put a colon between the hours and minutes I get the desired output:
>> Chronic.parse("12:34")
=> Wed Sep 16 12:34:00 -0600 2009
I am however wanting to pass the value without a colon, like this:
>> Chronic.parse("1234")
=> Wed Sep 16 12:34:00 -0600 2009
What string do I have to pass to the parser in order for Chronic to interpret "1234" as 12:34 PM of the current day?
I'm not certain, but it looks like it might be a bug. My guess is you're ending up in this corner of the code:
http://github.com/mojombo/chronic/commit/c7d9591acf5179345cbc916bd509c48acee8e744