Procmail to process a forwarded email - procmail

I want to process incoming forwarded emails received by procmail to grab the subject and recipient of the forwarded (child) email.
For example:
UserA receives an email from UserB
UserA forwards that email to the email server
email server receives the email and extracts UserB's email address
Is there an approach or recipe that performs this task? Or do I have to regex my way through the body of the main email?
EDIT:
By request, I will offer boundary conditions. Email clients of the 'UserA group' are Gmail and Outlook. All users sending in English. The 'UserB' is an automated agent under my control.
One of my servers ('User B') sends automated emails to my users ('UserA') who are supposed to forward the email to a second server for processing (to confirm they received the automated email).
I assume, then, that there are no consistent headers for forwarding and that I am needing to regex my way through the email to extract the data I need.

(This isn't really a proper answer, but I cannot use formatting in comments, so here goes.)
Depends on what you mean by "forwards". If you mean "uses the 'Forward' button in a sane email client" it could come out as an attachment (possibly with a content-transfer-encoding which needs to be decoded in order to access it) or an in-line copy of the original message as a textual body; or if you mean "uses the 'Forward' button in a broken email client, such as anything from Mordor Redmond" there are a number of possible additional complications. Technically, some clients might also "forward" by adding a "Resent-to:" header and otherwise just resending the original message verbatim. Or in some modern clients, you could drag the message over into the composition pane of a new empty message, and make it appear as an attachment to the new message, possibly with user control of the containing message's content-type and encoding, and the attachment's.
Assuming you end up with something like the following ...
From: UserA <usera#such.example.com>
To: server#example.net
Subject: VB: Hi
Hey, here is a message I received.
-- User A
---- Ursprungligt meddelande ----
Från: UserB [mailto:userb#elsewhere.example.org]
Till: UserA
Ämne: Hi
Datum: perjantai 13. lokakuuta 2012 23:45
Here is the original message
-- User B
.... the representation really isn't suitable for automatic processing. You can come up with heuristics such as identifying the "original message" separator and the first (possibly localized and mutilated) "to:" field after the separator, perhaps by requiring all messages to be from a particular version of a particular client with a particular locale setting, but in the general case, this cannot be solved reliably.
(For fun, I constructed an example from a Swedish localization running with Finnish system settings; so the labels from the client are in Swedish, but the system's date is in Finnish.)
If you can edit your question to include an example of a forwarded message and maybe some boundary conditions (it's always from the same user, the version and localization of the client software she uses will not change, etc, perhaps) we can try to take it from there.

Related

sending the verification code to the SMS and not to the application

is it possible to define how the verification code will be sent when calling the LoginUserIfNeeded method? I need to send it via SMS and not to the application.
Telegram servers decide by themselves through which method to send the code initially.
However if the user did not receive the code (eventually after a given timeout), he can request the code to be sent through an alternative method:
In WTelegramClient, this is done by returning an empty string for "verification_code" (typically, only on the first try)
You should probably first check through which medium Telegram sent the code:
The client.OnUpdate event receives a Auth_SentCode object specifying details (type) about the transmitted verification code. Then you can decide to reply the empty string only if it was transmitted through a medium you don't have access to.
You can check via the Auth_SentCode.next_type field which method will be used to send the code on the next try. (and you can possibly reply an empty verification_code again to try yet another method)
Additionally, on the call to LoginUserIfNeeded you can pass a CodeSettings instance which offer some limited options about the enabled methods for sending of the code.

How many Tasks can I add to a Chilkat Task Chain?

How many Tasks can I add to a Task Chain? I'm using the ActiveX component.
Specifically I'm adding emails using MailMan.SendMailAsync and will have thousands of emails queued.
Theoretically there is no limit, other than eventual memory limitations.
In any case, I wouldn't recommend it as a solution for sending thousands of emails. The reason is that here is no good way to handle external problems that may occur midway in the sending process, such as network or mail server problems.
A better and more scalable approach might be to write all the .eml files to a directory. You could write code to do the following until the "mail queue directory" is empty.
Select a .eml in the directory.
Load it into a Chilkat Email object.
Send the email using Chilkat MailMan via the SendEmail or SendEmailAsync method.
If your programming language allows you to create background threads, then you could create N threads, each with its own MailMan object that does the above. You would want to control/synchronize access to .eml files in some way to ensure that no two threads simultaneously choose the same .eml file. Also, N would limited to the number of connections from the same IP an SMTP server might allow.
If you're sending the same email to each recipient, or the same email template with replacements, then there's no need to actually write the full email for every recipient ahead of time. You could just manage the list, and for each subsequent email just update it with a new To/CC/BCC address (taking care to clear the To/CC/BCC email addresses from the Email object prior to calling AddTo/AddCc/AddBcc to add the new email address, otherwise the recipient list in the email grows with each iteration), do subject/body string replacements, etc. and send.

Receiving complaints for SES transactional emails - are TiS notifications generated by filters?

We're doing everything we can think of to limit the number of complaints we receive and will immediately remove anyone who marks us as junk that does not need to receive our emails. However, the last handful of complaints we've received have come from transactional emails of people who are receiving our company's services and NEED to receive everything we send transactionally as a critical part of our service. (e.g. We are booking their travel on their behalf and we need to send them verification emails to confirm their booking details.)
We're assuming that most of these complaints are somehow either false positives or are being done on accident. One customer confirmed that they did not click the junk mail button but it ended up in their junk folder and they moved it to their inbox. Some questions:
Can a TiS complaint be triggered by any means other than the user manually marking an email as junk in their email client? (Can automatic spam filters trigger this complaint? AWS documentation specifies only clicking the junk button.)
Besides contacting each individual personally, what would you suggest we do? Our complaint rate is continuing to rise even though we are taking action on every one.

How I use custom local_part of email address in Amazon Simple Email Service?

When I first sent a test message with Amazon SES, the MAIL_FROM was 0101015825ed6274-5b0cad8d-ddb6-425b-9802-782cc554497a-000000#us-west-2.amazonses.com.
In most email programs that address is hidden in the header, and it appears to be FROM a more human-friendly address. This is not the case when using an email to MMS gateway, which displays the spammy looking MAIL_FROM address to the user.
I figured out how to change the MAIL_FROM domain, but that just changes it to something like: 0101015825ed6274-5b0cad8d-ddb6-425b-9802-782cc554497a-000000#my_domain.com.
Is it possible to change the spammy-looking string of characters in the MAIL_FROM to a customized, human-friendly, less spammy-looking local_part of the address?
It is not possible.
The local_part of the MAIL FROM address is a unique, opaque identifier that SES uses for feedback tracking -- linking backsplatter bounces from poorly-behaving mail gateways that "reject" undeliverable mail by first accepting it and then firing back a separate bounce message... as well as spam complaints and out-of-office auto-responders, back to the original sender, message, and recipient.
That's why of the configuration of a custom MAIL FROM domain involves setting the domain's MX record to point to feedback-smtp.[aws-region].amazonses.com -- it collects those responses and correlates them back to the original message.
Techniques of this nature are necessary due to weaknesses in the design of SMTP itself, where it is difficult, unreliable, or impossible to otherwise correlate such events back to the original message that actually triggered them.

How to send mass mail in Django and get status for every message?

I'm creating a web app for handling various surveys. An admin can create his own survey and ask users to fill it up. Users are defined by target groups assigned to the survey (so only user in survey's target group can fill the survey).
One of methods to define a target group is a "Token target group". An admin can decide to generate e.g. 25 tokens. After that, the survey can be accessed by anyone who uses a special link (containing the token of course).
So now to the main question:
Every token might have an e-mail address associated with itself. How can I safely send e-mails containing the access link for the survey? I might need to send a few thousand e-mails (max. 10 000 I believe). This is an extreme example and such huge mailings would be needed only occasionally.
But I also would like to be able to keep track of the e-mail message status (was it send or was there any error?). I would also like to make sure that the SMTP server doesn't block this mailing. It would also be nice if the application remained responsive :) (The task should run in background).
What is the best way to handle that problem?
As far as I'm concerned, the standard Django mailing feature won't be much help here. People report that setting up a connection and looping through messages calling send() on them takes forever. It wouldn't run "in background", so I believe that this could have negative impact on the application responsiveness, right?
I read about django-mailer, but as far as I understood the docs - it doesn't allow to keep track of the message status. Or does it?
What are my other options?
Not sure about the rest, but regardless for backgrounding the task (no matter how you eventually do it) you'll want to look for Celery
The key here is to reuse connection and to not open it again for each email. Here is a documentation on the subject.