Gammu: Error getting SMS status: Security error. Maybe no PIN? - sms

I runnng gammu-smsd v. 1.40.0.0-1 on Raspbian 10. I am able to send messages with both sendsms and through gammu-smsd. However, gammu-smsd does not receive messages. When I check my log file /var/log/gammu-smsd.log I see an error below. The modem is a Huawei MS2372. Can anyone advise how I can fix this?
Mon 2020/11/30 16:17:18 gammu-smsd[2761]: gammu: Leaving GSM_GetSecurityStatus
Mon 2020/11/30 16:17:18 gammu-smsd[2761]: gammu: Entering GSM_GetSMSStatus
Mon 2020/11/30 16:17:18 gammu-smsd[2761]: gammu: Getting SIM SMS status
Mon 2020/11/30 16:17:18 gammu-smsd[2761]: gammu: SENDING frame type 0x00/length 0x12/18
Mon 2020/11/30 16:17:18 gammu-smsd[2761]: gammu: 41A|54T|2B+|43C|50P|4DM|53S|3D=|22"|53S|4DM|22"|2C,|22"|53S|4DM AT+CPMS="SM","SM
Mon 2020/11/30 16:17:18 gammu-smsd[2761]: gammu: 22"|0D ".
Mon 2020/11/30 16:17:18 gammu-smsd[2761]: gammu: 1 "AT+CPMS="SM","SM""
Mon 2020/11/30 16:17:18 gammu-smsd[2761]: gammu: 2 "+CMS ERROR: 302"
Mon 2020/11/30 16:17:18 gammu-smsd[2761]: gammu: Checking line: +CMS ERROR: 302
Mon 2020/11/30 16:17:18 gammu-smsd[2761]: gammu: AT reply state: 5
Mon 2020/11/30 16:17:18 gammu-smsd[2761]: gammu: RECEIVED frame type 0x00/length 0x25/37
Mon 2020/11/30 16:17:18 gammu-smsd[2761]: gammu: 41A|54T|2B+|43C|50P|4DM|53S|3D=|22"|53S|4DM|22"|2C,|22"|53S|4DM AT+CPMS="SM","SM
Mon 2020/11/30 16:17:18 gammu-smsd[2761]: gammu: 22"|0D |0D |0A |2B+|43C|4DM|53S|20 |45E|52R|52R|4FO|52R|3A:|20 "...+CMS ERROR:
Mon 2020/11/30 16:17:18 gammu-smsd[2761]: gammu: 333|300|322|0D |0A 302..
Mon 2020/11/30 16:17:18 gammu-smsd[2761]: gammu: CMS Error 302: "operation not allowed"
Mon 2020/11/30 16:17:18 gammu-smsd[2761]: gammu: GSM_GetSMSStatus failed with error SECURITYERROR[23]: Security error. Maybe no PIN?
Mon 2020/11/30 16:17:18 gammu-smsd[2761]: gammu: Leaving GSM_GetSMSStatus
Mon 2020/11/30 16:17:18 gammu-smsd[2761]: Error getting SMS status: Security error. Maybe no PIN? (SECURITYERROR[23])

Related

Need a Extract XPath help on an Email using webhook.site

I am needing to extract specific lines from a raw email that i have coming into my webhook.site url. I figured it would be an xpath extract or some custom action but my knowledge only goes so far.
i need to extract: Subject: which is the header about the content-type: text/plain.
Whats my path and layout to do so??
thanks
Return-Path: <leadnotification-noreply2#ylopo.com>
Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53])
by inbound-smtp.eu-west-1.amazonaws.com with SMTP id nqoso8q41s14sho14modqhpqbqvvvcqb0e3hea81
for OsirsYlopoPriorityEmail#email.webhook.site;
Wed, 27 Oct 2021 19:21:34 +0000 (UTC)
X-SES-Spam-Verdict: PASS
X-SES-Virus-Verdict: PASS
Received-SPF: pass (spfCheck: domain of ylopo.com designates 209.85.167.53 as permitted sender) client-ip=209.85.167.53; envelope-from=leadnotification-noreply2#ylopo.com; helo=mail-lf1-f53.google.com;
Authentication-Results: amazonses.com;
spf=pass (spfCheck: domain of ylopo.com designates 209.85.167.53 as permitted sender) client-ip=209.85.167.53; envelope-from=leadnotification-noreply2#ylopo.com; helo=mail-lf1-f53.google.com;
dkim=pass header.i=#ylopo.com;
dmarc=pass header.from=ylopo.com;
X-SES-RECEIPT: AEFBQUFBQUFBQUFHdlpaMkNVNS9wd25QYmtqSU9xbGJBVzZJa0tSV1dCNWcwWFFwZFNUS1lweHpxY1A1NlRoSlZyU1NEM0drMlp3Q0Jpd0d2ZG1RUC9VYVRCbWt6UUhMdkFwOUJLS1NGYnFCSzQyVGpQK1loZzU0SkpIcy9pNnQ4aHhScnV2dG9sV2M5b2VnSzY4MU0vMm9JaWx5VDJOcW5WWllPRzhvNkp6VHdJSWNmbmJBd1lvZlF1WHdEQUNFRzkyM0dQQVkxdGgwS0NwUHAzcVo5dit5clgvOXFzdG8xMFJaTVpuMVRLcXUwVDNNMVRod3lWSDB0NStRNjNUcEMrZ2RwZ0dSZFBQcEQ2OXZ2bUFOMkI3UUhJYUNZdG5iM2hqMUZhV1NST0FBbHdwSUM5TDIySk11dWh2alN3VE9BbVhGWjlKditMUzQ9
X-SES-DKIM-SIGNATURE: a=rsa-sha256; q=dns/txt; b=AXzUmXzoB1/c89r/6eJBBuEUriK6kdQMMJRXPnBwlUC5oCKD1Apk+Av3zpg5yxj+4djsbxeCsSPIwkcYX6xlXUfWUQ/mi7pgHViuVh+r/NrEKptMjb5efdeH7/mls8tRzyaQQF+12LbSb0wBo2bTkcQLXkP3WvKP5OSFde3B620=; c=relaxed/simple; s=uku4taia5b5tsbglxyj6zym32efj7xqv; d=amazonses.com; t=1635362495; v=1; bh=5WqfRbOb11+ge2mx0Egi4AqA6n1lyVIU1IpAVg4H0dA=; h=From:To:Cc:Bcc:Subject:Date:Message-ID:MIME-Version:Content-Type:X-SES-RECEIPT;
Received: by mail-lf1-f53.google.com with SMTP id y26so8295478lfa.11
for <OsirsYlopoPriorityEmail#email.webhook.site>; Wed, 27 Oct 2021 12:21:34 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=ylopo.com; s=google;
h=mime-version:from:date:message-id:subject:to;
bh=nrZwBjOzEgZN0tQ61MtDEDWEj3XJn2q+y4Qx1/acY5A=;
b=gtj7GzFH9q0O2S1ynt3Qvhp5zgomrYmufqbSQ0qIjEalwk9Dd0lSI7MeOMrgNtjDFL
sGwRBO9L4ZW3yE5ZKmP/wSYKmVlerL51ZlTQQhuTXsxioymJto3j0ERWirJQj+BapzGT
HBxScQEwYkpqZqWX6KkCTjCzCGZqW+fp9vitHmgfqt1/nLiyZp+7WEbluw+rPQO0G7dR
CGObjTeYa0Fd+Dc8h/k/a7suZ2umrqqnl/HYaoY7BeMxhAJDP5TuaoAsjQh1EU9zqHY8
TJxcJZoo83n+7f8qVMSNpAstVynlmsH6h7nzW1q27pfeWWY6LgMRUjkKqrYIc4F8lsqR
98SQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
bh=nrZwBjOzEgZN0tQ61MtDEDWEj3XJn2q+y4Qx1/acY5A=;
b=D/VtUGyzcVfTxi2x63V/3OC7ckHj1uuLlILVUNmOkMrvW6GWUJq7mKI9/D4UYXWc5i
Ybds0/Dktx6cDJUZbAiAYWOiYd56XMMc2O+Yoe36u+eREry29IJQXOLTcRj2KFcLGSWa
Me5GjcFPVBTuhjtxlPb41wCKhGmDevYEHDkbGIcoNp5w3weGobSPg8bLQNsEO/Hspn6y
4Q18s7uNIJ8X2o5DEevA8DrZfibThQ3X5HUFmpuaRT3089Qm3H92wiHv3rkn3fQFDnVY
4p/PcWw9bxK6pU47bBtO/qtJ2ce/3Q7OQq/NCvJ5ZjD83lRai1mKIaCtiyt3gccQrd5S
hc5g==
X-Gm-Message-State: AOAM531woVO34G4bG9aVBLV9ae6QgX8pklYV4DDYs4VALPxuz7W9GStL
QM3YDolGrDOXbzaZghT/1+So8DR3WqejlOCELMsa+zO2Xxs=
X-Google-Smtp-Source: ABdhPJylxjs2zEdxsuBr2M1l9CnsOHrWvk+53vOLw2bs77bdl75s4022uZaKlqYx/GG+UyEsRrt8DT6mRRCAQZSebbE=
X-Received: by 2002:a05:6512:acf:: with SMTP id n15mr578213lfu.222.1635362493750;
Wed, 27 Oct 2021 12:21:33 -0700 (PDT)
Received: from 927538837578 named unknown by gmailapi.google.com with
HTTPREST; Wed, 27 Oct 2021 12:21:33 -0700
MIME-Version: 1.0
From: leadnotification-noreply2#ylopo.com
Date: Wed, 27 Oct 2021 12:21:33 -0700
Message-ID: <CAN2r-3o0aD_98y2GrdxdBW7W6UHi8RMS9-JmvsHrftheurwMeQ#mail.gmail.com>
Subject: Ylopo Priority Alert - Party: Daniel Askew 19293 -
PRIORITY_LEAD_EVENT - massaquoimartha#yahoo.com - 8562838525
To: OsirsYlopoPriorityEmail#email.webhook.site, qojfsghi#mailparser.io
Content-Type: multipart/alternative; boundary="00000000000084f8be05cf5a80dc"
--00000000000084f8be05cf5a80dc
Content-Type: text/plain; charset="UTF-8"
Lead Name: Martha Mansaray
Lead Email: massaquoimartha#yahoo.com
Lead Phone: 8562838525
Text:
Ylopo PRIORITY LEAD ALERT: Martha Mansaray (856) 283-8525
Martha Mansaray VIEWED 6185 Old Highway 31E, Bethpage, TN
<https://andrea.livetn.com/listing-detail/124037148> 29 TIMES.
Recommend actions:
I think you need regex because XPath is used to find a node from XML/HTML type text. But regex can be used on any text. To get the value of header name "Subject" you can use regex \nSubject: (.*).
Python example:
import re
sample = """
...
<text you want to parse>
...
Subject: Ylopo Priority Alert - Party: Daniel Askew 19293 -
"""
if match := re.search(r"\nSubject: (.*)", sample):
print(match.group(1)) # output: Ylopo Priority Alert - Party: Daniel Askew 19293 -

Ruby array of hashes find values by key [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have an array like below
[{500=>{"id"=>1, "name"=>"Hock Tong Bee Pte Ltd/ Corner stone wines",
"created_at"=>Thu, 19 Jan 2017 18:10:35 UTC +00:00, "updated_at"=>Thu,
19 Jan 2017 18:10:35 UTC +00:00, "website"=>nil, "status"=>nil,
"industry_type_id"=>1, "major_category_id"=>1,
"minor_category_id"=>75, "save_as_draft"=>false, "company_id"=>1}},
{600=>{"id"=>2, "name"=>"Continental Wines", "created_at"=>Thu, 19 Jan
2017 18:10:35 UTC +00:00, "updated_at"=>Thu, 19 Jan 2017 18:10:35 UTC
+00:00, "website"=>nil, "status"=>nil, "industry_type_id"=>1, "major_category_id"=>1, "minor_category_id"=>75,
"save_as_draft"=>false, "company_id"=>2}}]
I have key's like 500/600 from this array i want tot get that object.
I need to write one method, I will pass key only that should return appropriate object. Example if I send key is 500 result should be
{"id"=>1, "name"=>"Hock Tong Bee Pte Ltd/ Corner stone wines",
"created_at"=>Thu, 19 Jan 2017 18:10:35 UTC +00:00, "updated_at"=>Thu,
19 Jan 2017 18:10:35 UTC +00:00, "website"=>nil, "status"=>nil,
"industry_type_id"=>1, "major_category_id"=>1,
"minor_category_id"=>75, "save_as_draft"=>false, "company_id"=>1}
Anyone have idea on how to achieve this in Ruby?
I believe simple reduce method should work:
hash = [{500=>{"id"=>1, "name"=>"Hock Tong Bee Pte Ltd/ Corner stone wines", "created_at"=>"Thu, 19 Jan 2017 18:10:35 UTC +00:00", "updated_at"=>"Thu, 19 Jan 2017 18:10:35 UTC +00:00", "website"=>nil, "status"=>nil, "industry_type_id"=>1, "major_category_id"=>1, "minor_category_id"=>75, "save_as_draft"=>false, "company_id"=>1}}, {600=>{"id"=>2, "name"=>"Continental Wines", "created_at"=>"Thu, 19 Jan 2017 18:10:35 UTC +00:00", "updated_at"=>"Thu, 19 Jan 2017 18:10:35 UTC +00:00", "website"=>nil, "status"=>nil, "industry_type_id"=>1, "major_category_id"=>1, "minor_category_id"=>75, "save_as_draft"=>false, "company_id"=>2}}]
your_value = hash.reduce({}) { |h, v| h.merge v }[500]

Inbound emails using webhook with Mandrill Ruby

According to the documentation, we should be looking at a parameter called "message", which doesn't not come in. What does come in is a parameter called "mandrill_events".
require 'mail'
class InboxController < ApplicationController
skip_before_filter :verify_authenticity_token, only: :create
def create
mail = Mail.new(params[:message])
....
No dice, but I do see this in the console log when I use the following syntax (note, it's so much JSON that SO has trouble viewing it with formatting):
puts JSON.parse(params[:mandrill_events])
{"mandrill_events"=>"[{\"event\":\"inbound\",\"ts\":1426188360,\"msg\":{\"raw_msg\":\"Received: from mail-ob0-f181.google.com (unknown [209.85.214.181])\\n\\tby ip-10-39-136-77 (Postfix) with ESMTPS id 25B0E2C0509\\n\\tfor <test#inbound.diabetesdelivery.com>; Thu, 12 Mar 2015 19:26:00 +0000 (UTC)\\nReceived: by obcvb8 with SMTP id vb8so16123307obc.10\\n for <test#inbound.diabetesdelivery.com>; Thu, 12 Mar 2015 12:25:59 -0700 (PDT)\\nDKIM-Signature: v=1; a=rsa-sha256; c=relaxed\\/relaxed;\\n d=gmail.com; s=20120113;\\n h=mime-version:date:message-id:subject:from:to:content-type;\\n bh=jyd6a9aMNBrnuDpbsOEokXnACKw\\/lLnh72zkG7LCs3c=;\\n b=wzt6xiplBtL6dq7uGR8RV6tRR9Lcsmj5zmIktZ7KXFcxbwezN+uEhK\\/XFw6ZjIfhp6\\n LVoEH5ljLjOwK4X4nrtHaPoNzHZizwQUzxk0qXGabTXHW6tqOLZUs3FeDwtt2ekeLvlb\\n bDuU4VcBnNZ5VkXDpA5hQeysCfGECBilAtMy\\/EBjdOngcgk4Fsp8u11\\/eeB2xqBPUcrR\\n JYeu\\/99XossdoeJW3avfxFDBw7ngc98oRS2ZPpyL7MY36XoCZCM25U9ue9kBcJ82n92i\\n ctbNdl+9ikVPdcmUokI0WIvBIBGl5yAcrvOQffxmaTz0c31fkq8+iyprDMP\\/GexVfQzN\\n SAKA==\\nMIME-Version: 1.0\\nX-Received: by 10.202.89.135 with SMTP id n129mr34093639oib.60.1426188359432;\\n Thu, 12 Mar 2015 12:25:59 -0700 (PDT)\\nReceived: by 10.60.119.68 with HTTP; Thu, 12 Mar 2015 12:25:59 -0700 (PDT)\\nDate: Thu, 12 Mar 2015 12:25:59 -0700\\nMessage-ID: <CAMf1_47jvgW6QMwDx8R9JU6C5YiUMaPjvFz3muxhM5v4HJyoSg#mail.gmail.com>\\nSubject: Subject FTW?\\nFrom: Dee diabetic <Deediabetic#gmail.com>\\nTo: test#inbound.diabetesdelivery.com\\nContent-Type: multipart\\/alternative; boundary=001a113d39288bfe8505111c5a88\\n\\n--001a113d39288bfe8505111c5a88\\nContent-Type: text\\/plain; charset=UTF-8\\n\\nBody here\\n\\n--001a113d39288bfe8505111c5a88\\nContent-Type: text\\/html; charset=UTF-8\\n\\n<div dir=\\\"ltr\\\">Body here<\\/div>\\n\\n--001a113d39288bfe8505111c5a88--\",\"headers\":{\"Received\":[\"from mail-ob0-f181.google.com (unknown [209.85.214.181]) by ip-10-39-136-77 (Postfix) with ESMTPS id 25B0E2C0509 for <test#inbound.diabetesdelivery.com>; Thu, 12 Mar 2015 19:26:00 +0000 (UTC)\",\"by obcvb8 with SMTP id vb8so16123307obc.10 for <test#inbound.diabetesdelivery.com>; Thu, 12 Mar 2015 12:25:59 -0700 (PDT)\",\"by 10.60.119.68 with HTTP; Thu, 12 Mar 2015 12:25:59 -0700 (PDT)\"],\"Dkim-Signature\":\"v=1; a=rsa-sha256; c=relaxed\\/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=jyd6a9aMNBrnuDpbsOEokXnACKw\\/lLnh72zkG7LCs3c=; b=wzt6xiplBtL6dq7uGR8RV6tRR9Lcsmj5zmIktZ7KXFcxbwezN+uEhK\\/XFw6ZjIfhp6 LVoEH5ljLjOwK4X4nrtHaPoNzHZizwQUzxk0qXGabTXHW6tqOLZUs3FeDwtt2ekeLvlb bDuU4VcBnNZ5VkXDpA5hQeysCfGECBilAtMy\\/EBjdOngcgk4Fsp8u11\\/eeB2xqBPUcrR JYeu\\/99XossdoeJW3avfxFDBw7ngc98oRS2ZPpyL7MY36XoCZCM25U9ue9kBcJ82n92i ctbNdl+9ikVPdcmUokI0WIvBIBGl5yAcrvOQffxmaTz0c31fkq8+iyprDMP\\/GexVfQzN SAKA==\",\"Mime-Version\":\"1.0\",\"X-Received\":\"by 10.202.89.135 with SMTP id n129mr34093639oib.60.1426188359432; Thu, 12 Mar 2015 12:25:59 -0700 (PDT)\",\"Date\":\"Thu, 12 Mar 2015 12:25:59 -0700\",\"Message-Id\":\"<CAMf1_47jvgW6QMwDx8R9JU6C5YiUMaPjvFz3muxhM5v4HJyoSg#mail.gmail.com>\",\"Subject\":\"Subject FTW?\",\"From\":\"Dee diabetic <Deediabetic#gmail.com>\",\"To\":\"test#inbound.diabetesdelivery.com\",\"Content-Type\":\"multipart\\/alternative; boundary=001a113d39288bfe8505111c5a88\"},\"text\":\"Body here\\n\\n\",\"text_flowed\":false,\"html\":\"<div dir=\\\"ltr\\\">Body here<\\/div>\\n\\n\",\"from_email\":\"Deediabetic#gmail.com\",\"from_name\":\"Dee diabetic\",\"to\":[[\"test#inbound.diabetesdelivery.com\",null]],\"subject\":\"Subject FTW?\",\"spf\":{\"result\":\"pass\",\"detail\":\"sender SPF authorized\"},\"spam_report\":{\"score\":0.5,\"matched_rules\":[{\"name\":\"RCVD_IN_DNSWL_LOW\",\"score\":-0.7,\"description\":\"RBL: Sender listed at http:\\/\\/www.dnswl.org\\/, low\"},{\"name\":null,\"score\":0,\"description\":null},{\"name\":\"listed\",\"score\":0,\"description\":\"in list.dnswl.org]\"},{\"name\":\"FREEMAIL_FROM\",\"score\":0,\"description\":\"Sender email is commonly abused enduser mail provider\"},{\"name\":\"HTML_MESSAGE\",\"score\":0,\"description\":\"BODY: HTML included in message\"},{\"name\":\"DKIM_VALID_AU\",\"score\":-0.1,\"description\":\"Message has a valid DKIM or DK signature from author's\"},{\"name\":\"DKIM_SIGNED\",\"score\":0.1,\"description\":\"Message has a DKIM or DK signature, not necessarily valid\"},{\"name\":\"DKIM_VALID\",\"score\":-0.1,\"description\":\"Message has at least one valid DKIM or DK signature\"},{\"name\":\"RDNS_NONE\",\"score\":1.3,\"description\":\"Delivered to internal network by a host with no rDNS\"}]},\"dkim\":{\"signed\":true,\"valid\":true},\"email\":\"test#inbound.diabetesdelivery.com\",\"tags\":[],\"sender\":null,\"template\":null}}]"}
Mar 12 12:26:046666 app/web.1: {"event"=>"inbound", "ts"=>1426188360, "msg"=>{"raw_msg"=>"Received: from mail-ob0-f181.google.com (unknown [209.85.214.181])\n\tby ip-10-39-136-77 (Postfix) with ESMTPS id 25B0E2C0509\n\tfor ; Thu, 12 Mar 2015 19:26:00 +0000 (UTC)\nReceived: by obcvb8 with SMTP id vb8so16123307obc.10\n for ; Thu, 12 Mar 2015 12:25:59 -0700 (PDT)\nDKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=gmail.com; s=20120113;\n h=mime-version:date:message-id:subject:from:to:content-type;\n bh=jyd6a9aMNBrnuDpbsOEokXnACKw/lLnh72zkG7LCs3c=;\n b=wzt6xiplBtL6dq7uGR8RV6tRR9Lcsmj5zmIktZ7KXFcxbwezN+uEhK/XFw6ZjIfhp6\n LVoEH5ljLjOwK4X4nrtHaPoNzHZizwQUzxk0qXGabTXHW6tqOLZUs3FeDwtt2ekeLvlb\n bDuU4VcBnNZ5VkXDpA5hQeysCfGECBilAtMy/EBjdOngcgk4Fsp8u11/eeB2xqBPUcrR\n JYeu/99XossdoeJW3avfxFDBw7ngc98oRS2ZPpyL7MY36XoCZCM25U9ue9kBcJ82n92i\n ctbNdl+9ikVPdcmUokI0WIvBIBGl5yAcrvOQffxmaTz0c31fkq8+iyprDMP/GexVfQzN\n SAKA==\nMIME-Version: 1.0\nX-Received: by 10.202.89.135 with SMTP id n129mr34093639oib.60.1426188359432;\n Thu, 12 Mar 2015 12:25:59 -0700 (PDT)\nReceived: by 10.60.119.68 with HTTP; Thu, 12 Mar 2015 12:25:59 -0700 (PDT)\nDate: Thu, 12 Mar 2015 12:25:59 -0700\nMessage-ID: \nSubject: Subject FTW?\nFrom: Dee diabetic \nTo: test#inbound.diabetesdelivery.com\nContent-Type: multipart/alternative; boundary=001a113d39288bfe8505111c5a88\n\n--001a113d39288bfe8505111c5a88\nContent-Type: text/plain; charset=UTF-8\n\nBody here\n\n--001a113d39288bfe8505111c5a88\nContent-Type: text/html; charset=UTF-8\n\nBody here\n\n--001a113d39288bfe8505111c5a88--", "headers"=>{"Received"=>["from mail-ob0-f181.google.com (unknown [209.85.214.181]) by ip-10-39-136-77 (Postfix) with ESMTPS id 25B0E2C0509 for ; Thu, 12 Mar 2015 19:26:00 +0000 (UTC)", "by obcvb8 with SMTP id vb8so16123307obc.10 for ; Thu, 12 Mar 2015 12:25:59 -0700 (PDT)", "by 10.60.119.68 with HTTP; Thu, 12 Mar 2015 12:25:59 -0700 (PDT)"], "Dkim-Signature"=>"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=jyd6a9aMNBrnuDpbsOEokXnACKw/lLnh72zkG7LCs3c=; b=wzt6xiplBtL6dq7uGR8RV6tRR9Lcsmj5zmIktZ7KXFcxbwezN+uEhK/XFw6ZjIfhp6 LVoEH5ljLjOwK4X4nrtHaPoNzHZizwQUzxk0qXGabTXHW6tqOLZUs3FeDwtt2ekeLvlb bDuU4VcBnNZ5VkXDpA5hQeysCfGECBilAtMy/EBjdOngcgk4Fsp8u11/eeB2xqBPUcrR JYeu/99XossdoeJW3avfxFDBw7ngc98oRS2ZPpyL7MY36XoCZCM25U9ue9kBcJ82n92i ctbNdl+9ikVPdcmUokI0WIvBIBGl5yAcrvOQffxmaTz0c31fkq8+iyprDMP/GexVfQzN SAKA==", "Mime-Version"=>"1.0", "X-Received"=>"by 10.202.89.135 with SMTP id n129mr34093639oib.60.1426188359432; Thu, 12 Mar 2015 12:25:59 -0700 (PDT)", "Date"=>"Thu, 12 Mar 2015 12:25:59 -0700", "Message-Id"=>"", "Subject"=>"Subject FTW?", "From"=>"Dee diabetic ", "To"=>"test#inbound.diabetesdelivery.com", "Content-Type"=>"multipart/alternative; boundary=001a113d39288bfe8505111c5a88"}, "text"=>"Body here\n\n", "text_flowed"=>false, "html"=>"Body here\n\n", "from_email"=>"Deediabetic#gmail.com", "from_name"=>"Dee diabetic", "to"=>[["test#inbound.diabetesdelivery.com", nil]], "subject"=>"Subject FTW?", "spf"=>{"result"=>"pass", "detail"=>"sender SPF authorized"}, "spam_report"=>{"score"=>0.5, "matched_rules"=>[{"name"=>"RCVD_IN_DNSWL_LOW", "score"=>-0.7, "description"=>"RBL: Sender listed at http://www.dnswl.org/, low"}, {"name"=>nil, "score"=>0, "description"=>nil}, {"name"=>"listed", "score"=>0, "description"=>"in list.dnswl.org]"}, {"name"=>"FREEMAIL_FROM", "score"=>0, "description"=>"Sender email is commonly abused enduser mail provider"}, {"name"=>"HTML_MESSAGE", "score"=>0, "description"=>"BODY: HTML included in message"}, {"name"=>"DKIM_VALID_AU", "score"=>-0.1, "description"=>"Message has a valid DKIM or DK signature from author's"}, {"name"=>"DKIM_SIGNED", "score"=>0.1, "description"=>"Message has a DKIM or DK signature, not necessarily valid"}, {"name"=>"DKIM_VALID", "score"=>-0.1, "description"=>"Message has at least one valid DKIM or DK signature"}, {"name"=>"RDNS_NONE", "score"=>1.3, "description"=>"Delivered to internal network by a host with no rDNS"}]}, "dkim"=>{"signed"=>true, "valid"=>true}, "email"=>"test#inbound.diabetesdelivery.com", "tags"=>[], "sender"=>nil, "template"=>nil}}
So I am getting a JSON string, but how exactly is the best way to grab the TO, FROM, and SUBJECT?
Update: I just tried the following:
tester = JSON.parse(params[:mandrill_events])
puts tester[:msg][:subject]
#and even this
puts tester["msg"]["subject"]
Did not work. Got an error: **TypeError (no implicit conversion of String into Integer): **
After a day of banging my head, I came up with the solution. By the way, accessing the values directly doesn't work. I had to loop into it.
incomingMail = params[:mandrill_events]
mail_from = "Cannot read From"
mail_originally_to = "Cannot read To"
mail_subject = "No subject"
mail_date = ""
mail_body = "No email body"
if incomingMail != nil
incomingMail = JSON.parse(incomingMail)
incomingMail.each do |item|
mail_from = item["msg"]["from_email"]
mail_originally_to = item["msg"]["headers"]["To"]
mail_subject = item["msg"]["subject"]
mail_date = item["msg"]["headers"]["Date"]
mail_body = item["msg"]["text"]
mail_body_html = item["msg"]["html"]
end
#Confirm
else
puts "Email not sent. Parameter invalid."
end

Remove "invalid byte sequence in UTF-8" after an apparently succesfull encoding

I have an IMAP mail with a message string that looks like this:
message = #<Mail::Message:70152447148720, Multipart: false, Headers: <Return-Path: <apache#mail.gameseek.co.uk>>, <Received: by 10.86.68.12 with SMTP id q12cs352558fga; Mon, 9 Mar 2009 04:23:05 -0700 (PDT)>, <Received: by 10.210.137.14 with SMTP id k14mr2429643ebd.46.1236597783700; Mon, 09 Mar 2009 04:23:03 -0700 (PDT)>, <Received: from exproxy-2.exserver.dk (exproxy-2.exserver.dk [195.69.129.163]) by mx.google.com with ESMTP id 27si3500694ewy.75.2009.03.09.04.23.03; Mon, 09 Mar 2009 04:23:03 -0700 (PDT)>, <Received: by exproxy-2.exserver.dk (Postfix, from userid 65534) id DF2F6106EF3; Mon, 9 Mar 2009 12:13:26 +0100 (CET)>, <Received: from exsmtp01.exserver.dk (exsmtp01.exserver.dk [195.69.129.177]) by exproxy-2.exserver.dk (Postfix) with ESMTP id C2CEE106ED0 for <support_email.com#exfwd01.scannet.dk>; Mon, 9 Mar 2009 12:13:26 +0100 (CET)>, <Received: from exsmtp02.exserver.dk ([10.10.10.32]) by exsmtp01.exserver.dk with Microsoft SMTPSVC(6.0.3790.1830); Mon, 9 Mar 2009 12:22:19 +0100>, <Received: from front08.exserver.dk ([195.69.129.93]) by exsmtp02.exserver.dk with Microsoft SMTPSVC(6.0.3790.1830); Mon, 9 Mar 2009 12:22:19 +0100>, <Received: from localhost (front08.exserver.dk [127.0.0.1]) by front08.exserver.dk (Postfix) with ESMTP id F1B2BC4028 for <support#email.com>; Mon, 9 Mar 2009 12:46:22 +0100 (CET)>, <Received: from front08.exserver.dk ([127.0.0.1]) by localhost (front08.exserver.dk [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mrYGo4G2pt13 for <support#email.com>; Mon, 9 Mar 2009 12:46:16 +0100 (CET)>, <Received: from mail.gameseek.co.uk (78.109.164.42.srvlist.ukfast.net [78.109.164.42]) by front08.exserver.dk (Postfix) with ESMTP id 99022C4021 for <support#email.com>; Mon, 9 Mar 2009 12:46:16 +0100 (CET)>, <Received: by mail.gameseek.co.uk (Postfix, from userid 48) id D321218DD2D; Mon, 9 Mar 2009 11:22:55 +0000 (GMT)>, <Date: Mon, 09 Mar 2009 11:22:55 +0000>, <From: myorder#gameseek.co.uk>, <Reply-To: myorder#gameseek.co.uk>, <To: support#email.com>, <Message-ID: <20090309112255.D321218DD2D#mail.gameseek.co.uk>>, <Subject: Gameseek Order Refunded: Gh68y1235386413>, <Delivered-To: my#email.com>, <Received-SPF: neutral (google.com: 195.69.129.163 is neither permitted nor denied by best guess record for domain of apache#mail.gameseek.co.uk) client-ip=195.69.129.163;>, <Authentication-Results: mx.google.com; spf=neutral (google.com: 195.69.129.163 is neither permitted nor denied by best guess record for domain of apache#mail.gameseek.co.uk) smtp.mail=apache#mail.gameseek.co.uk>, <X-Exserver-To: support_email.com#exfwd01.scannet.dk>, <X-Virus-Scanned: amavisd-new at exserver.dk>, <X-OriginalArrivalTime: 09 Mar 2009 11:22:19.0838 (UTC) FILETIME=[4F6005E0:01C9A0A9]>, <X-ScanNet-Forward: TTL=5>>
I now wish to give it a proper encoding:
unless message.multipart?
charset = message.charset # => "UTF-8"
if charset != nil
body = message.body.decoded.force_encoding(charset).encode("UTF-8") # => "\n\nHello you,\n\nYour order or part of it has been refunded by Gameseek. The refund will be present on the same payment method you used when purchasing. If no other items are due to be posted to you the postage charge will also be refunded.\n\nPlease allow upto four working days for this refund to process.\n\nIf you have not contacted us about this order then it is most likely you are being refunded for an item we cannot currently get hold of.\n\nWe do apologise if this is the case, we would rather refund customers rather than having them wait weeks and weeks for an item.\n\nIf you have contacted us about this order then you will know why you are being refunded.\nMay we apologise if we have not met your requirements on this occassion.\n\nYour Order: Product | Category | Quantity | Cost\n---------------------------------------------------\nDragon Ball Z - Supersonic Warriors 2 | NintendoDS | 1 | \xA326.97\n\n\nFor all order enquires please contact myorder#gameseek.co.uk\n\nThank you for using Gameseek.\n"
end
end
body = body.split(/Sent from my iPhone/)[0]
The last line raises the following error:
invalid byte sequence in UTF-8
Any idea how to fix this?
The text contains the invalid sequence \xA3. This represents a pound sign in Latin-1 (ISO-8859-1).
"\xA3".force_encoding('ISO-8859-1').encode('UTF-8')
#=> "£"
The quick fix is to replace invalid byte sequences in body with String#scrub, but that will remove them:
"\xA326.97".scrub('')
#=> "26.97"
However, to solve the "real" problem you should look earlier in the pipeline. The supplied charset seems to be wrong. Apparently the message is encoded in Latin-1, although the charset suggests something different. Maybe the problem is on the side of the sender.

Contact emails keep going to spam folder for almost everyone for Joomla component

We are using a Joomla component and all the messages for the "contact this advertiser" web form go directly to spam. We have tested many email accounts and have made every change I can think of. Any assistance would be great.
here is the page where the web form is:
http://www.shopforbiz.com/buy-a-business/ad/restaurants,26/franchise-sub-shop,31
Here is the email header information:
Delivered-To: adammotta#gmail.com
Received: by 10.194.27.195 with SMTP id v3csp56291wjg;
Thu, 7 Aug 2014 06:01:33 -0700 (PDT)
X-Received: by 10.68.113.133 with SMTP id iy5mr17521168pbb.135.1407416493076;
Thu, 07 Aug 2014 06:01:33 -0700 (PDT)
Return-Path: <inquiry#shopforbiz.com>
Received: from see.seekmomentum.com (see.seekmomentum.com. [198.57.217.77])
by mx.google.com with ESMTPS id ym5si3469643pab.6.2014.08.07.06.01.32
for <adammotta#gmail.com>
(version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
Thu, 07 Aug 2014 06:01:32 -0700 (PDT)
Received-SPF: pass (google.com: domain of inquiry#shopforbiz.com designates 198.57.217.77 as permitted sender) client-ip=198.57.217.77;
Authentication-Results: mx.google.com;
spf=pass (google.com: domain of inquiry#shopforbiz.com designates 198.57.217.77 as
permitted sender) smtp.mail=inquiry#shopforbiz.com
Received: from localhost ([127.0.0.1]:35995 helo=www.shopforbiz.com)
by see.seekmomentum.com with esmtpa (Exim 4.82)
(envelope-from <inquiry#shopforbiz.com>)
id 1XFNJz-0003RC-Jy
for adammotta#gmail.com; Thu, 07 Aug 2014 09:01:31 -0400
Date: Thu, 7 Aug 2014 09:01:31 -0400
To: adammotta#gmail.com
From: Shop For Biz <inquiry#shopforbiz.com>
Reply-To: inquiry#shopforbiz.com
Subject: New Inquiry from ShopforBiz
Message-ID: <18888aba9485a3ef865449febf2667c2#www.shopforbiz.com>
X-Priority: 3
X-Mailer: PHPMailer 5.2.6 (https://github.com/PHPMailer/PHPMailer/)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-AntiAbuse: This header was added to track abuse, please include it with any abuse report
X-AntiAbuse: Primary Hostname - see.seekmomentum.com
X-AntiAbuse: Original Domain - seekmomentum.com
X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse: Sender Address Domain - shopforbiz.com
X-Get-Message-Sender-Via: see.seekmomentum.com: authenticated_id: inquiry#shopforbiz.com
X-Source:
X-Source-Args:
X-Source-Dir:
From user: adam
User email: adamd#yaho.com
Your advertisement ''Carry Out Chicken, Ribs & Pizza'' enquiry
test

Resources