why I am getting the backslash () before the singlequote (') in my email body? email sent through PHPMailer.
Scenario:
In email : "I don\'t know who is Kiku!"
email screenshot
In database : "I don't know who is Kiku!"
database screnshot
Because someone messed up the code for sending the mail, most likely by redundantly escaping the string to send, thinking it will increase security. That's really all I can give you.
Related
I have huge logs to look through and need to replace some parts of the logs to a more generic profile.
For example, in the logs, there are many email address. Email address are recorded as such. There are no criteria to how the emails are records:
abc#gmail.com
abc_efg#gmail.com
Anyone have any knowledge on how to convert this email address using ReGex, to convert abc to user, regardless on how the email was stored as seen below?:
#gmail.com
The purpose of this program is so that I am able to hide the email address of the users, before sending the file to someone else.
Tried to use RegEx but I am not sure on how to proceed.
Hope someone is able to help! Thanks
import re
text = 'this is my email Kapil#gmail.com or may be not'
re.sub('[A-Za-z0-9_]*#.*\.com', '********', text)
This will take all the words contains alphanumeric sequence or _ then check it they contains '#' next and followed by your domain name which can be gmail or any other comapany name ending with .com
All these condition will ensure the sequence of word we captured is an email and it will replace than email with '********'.
I am using allauth's ResetPasswordForm for password reset process. This form's save method sends the password reset email. I customized the password reset template to use it in Turkish, so it includes some special characters. The email message itself is printed perfectly, displaying the special characters the right way. However, the subject line is printed as below for a subject I enter e.g. "öla".
"Subject: =?utf-8?b?W2V4YW1wbGUuY29tXSDDtmxh?="
If I give the subject "ola" without using the accent, there is no problem, it prints
"Subject: ola"
to the console. To stress again, this does not happen in the email body, which prints several special characters correctly. I only changed the allauth's template, and did not change anything in the form class.
Any idea how to fix this? Thanks.
I've got an email processing agent. It copies the body of the email into a document's rich text field. If there are any embedded links in the email I want to process that embedded link and extract the url. I started playing around with MIMEEntity but nothing came of it. Any ideas?
thanks
clem
================
Hi Rich,
Well here's a more robust explanation of what's going on. I have several Notes apps which deal with email correspondence. An email comes in, a Notes document is created with some meta data (system generated ID, user's email, name, company, status, etc). The email body is added to a 'correspondence' rich text field of the created Notes doc. The app allows for someone on our side to follow up on the email (ask a question, provide some feedback, etc). That response from us is pre-pended to the original email. If the original sender responds with some further information, THAT email is also pre-pended. To do this pre-pending, I do
bodyText = EmailDoc.GetFirstItem("Body").text
textFromNotesDoc = CTdoc.GetFirstItem("Issue").text
newTextFromNotesDoc = bodyText + <some stuff> + textFromNotesDoc
I then do a replace.
This worked perfectly fine for years. However, recently users have been sending in emails containing embedded links. Of course anything like that is lost when I do the NotesDocument.GetFirstItem().Text. So I've been trying to think of a way to capture the embedded link. The other day it occurred to me that if I could read the html, I could find and extract the url and simply add it to text. I thought maybe using NotesMIMEEntity would allow me to read through the body field and find the url but that's not working.
Clem
The solution is to NOT NotesDocument.GetFirstItem().Text. Just simply take the email coming in and prepend the body field to the discussion RT field. I add tags to the email going out so that I know if the person responding included the previous conversation. That took a little work to figure out but by using NotesRichTextNavigator and related classes, I'm able to deal with that.
clem
I am writing a simple software that needs to:
Connect to an IMAP server
Download all unread messages
Store each message's body, and attachment. I prefer the body as text.
Mark them as read
I am reading https://github.com/mscdex/node-imap; however, a message can be in multiple parts, and that's where I am lost. For example, when it's multi-part, what is the part that is guaranteed to be the actual email body?
Or, even better, is there a wrapper out there that will just return a nice "message" object, all neatly fetched and prepared for me? Something with the usual headers (from, to, etc.), to body, and a bunch of pre-decoded attachment?
Merc.
To answer the good part of your question: No part is guaranteed to be "the email body", you can legally send a message without text. I've seen software that'll send attachment-only mail when the user adds an attachment but leaves the mail body field empty. The way to distinguish between inline bodies and attachments is to look at the content-disposition field, and if that's not present, assume inline for text/* and attachment for other types. (Yes, this also means that there may be more than one inline body. Apple Mail is fond of sending that, for instance.)
The other part of your question is a FAQ and an easy one, and yes, there's much software to build that message object. Approximately 100% of client libraries can do that. Search your documentation for "bodystructure", that's the name of the IMAP fetch item they retrieve and parse in order to build the structure you want.
I have a website, and in the "Contact" section I have a form which users may fill in to contact me.
The form is a simple form which action is a php page.
The php code:
$to = "email#domain.com";
$name=$_POST['name']; // sender name
$email=$_POST['email']; // sender email
$tel= $_POST['tel']; // sender tel
$subject=$_POST['subject']; // subject CHOSEN FROM DROPLIST, ALL TESTED
$text=$_POST['text']; // Message from sender
$text.="\n\nTel:".$tel; // Added to message to show me the telephone nr to the sender at bottom of message
$headers="MIME-Version: 1.0"."\n";
$headers.="Content-type: text/plain; charset=UTF-8"."\n";
$headers.="From: $name <$email>"."\n";
mail($to, '=?UTF-8?B?'.base64_encode($subject).'?=', $text, $headers, '-fno-reply#domain.com');
Could somebody please tell me why this works most of the time, but sometimes I receive email whith no text and the subject line showing
=?UTF-8?B??=
I use outlook express, and I have read this System.Net.Mail and =?utf-8?B?XXXXX.... Headers
but it didn't help.
The problem is not in Outlook, because when I log in to the actual mailprogram where I fetch the POP3 emails from, the email looks the same.
When I right click in Outlook and chose "message source" then there is no "From" information.
Ex, a good message should look like this:
Subject: =?UTF-8?B?w5Z2cmlndA==?=
MIME-Version: 1.0
Content-type: text/plain; charset=UTF-8
From: John Doe
However, the ones with problem looks like this:
Subject: =?UTF-8?B??=
MIME-Version: 1.0
Content-type: text/plain; charset=UTF-8
From:
As if the information has been lost somewhere.
You should know also that I have a VPS, which I manage myself.
I use postfix as an emailserver, if thats got anything to do with it.
But then again, why does it work sometimes?
Also another thing that I have noticed is that sometimes special characters are not shown correctly (by both Outlook and the webmail).
For instance, the name "Björkman" in swedish is shown like Björkman, but again, only sometimes.
I hope anybody knows something about this problem, because it is very hard to track down for me atleast.
If you need more input let me know.
Looks like the form is posted with all fields left blank. There are bots crawling the net and submitting empty forms. Have you been able to reproduce this with actual form data?
Additional hint: your code is open to email header injection - I can post any headers I want, separated by line breaks, in $_POST['name'] and your code will put it into the email headers. At least remove any line breaks from user data that will go into the header section.