Menu
  • HOME
  • TAGS

Perl parsing multipart/alternative emails

perl,email,mime

Multiparts contain multiple parts. Iterate over them: use strict; use warnings; use Email::MIME; use Data::Printer; use feature qw/say/; my $source = <<EOF; Content-Type: multipart/related; boundary="_004_47C8E15E8EEDCB4E94E891F9414C019A0CB5BDEE79DFW1MBX07mex0_"; type="multipart/alternative" MIME-Version: 1.0 --_004_47C8E15E8EEDCB4E94E891F9414C019A0CB5BDEE79DFW1MBX07mex0_ Content-Type: multipart/alternative; boundary="_000_47C8E15E8EEDCB4E94E891F9414C019A0CB5BDEE79DFW1MBX07mex0_"...

Sending MIME-encoded email attachments with utf-8 filenames

php,email,pdf,utf-8,mime

According to RFC2047 you can't have encodings other than ascii in parameters of Content-Type header. According to RFC2231 you can try to define extended parameter: Content-Type: application/pdf; name*=utf-8''%D7%A9%D7%9C%D7%95%D7%9D%2E%70%64%66 I have no idea how well it is supported. I can't come up with oneliner for that, but you can try to...

How to send to BCC address when using PHPMailer to format MIME message for Gmail API?

php,gmail,phpmailer,mime,bcc

PHPMailer will track the BCC recipients internally and if you were to send the message with PHPMailer it would specify the BCC recipients during the SMTP envelope. However, when you extract the raw message from PHPMailer you lose the internal recipient list that PHPMailer was tracking. The raw message does...

How to add a “Body” to a python mime multipart(has attachment) email

python,python-3.x,mime,email-attachments,mime-mail

This is how I did it: body = "Text for body" msg.attach(MIMEText(body,'plain')) I did it after declaring subject and before attaching the file....

Can an email header have different character encoding than the body of the email?

email,mime,rfc822

Email headers should use the ASCII charset, if you want the header fields to have a different encoding you need to use the encoded word syntax: http://en.wikipedia.org/wiki/MIME#Encoded-Word The email body can be directly encoded in different encoding only if mail servers that transfer it have 8bit mime enabled (nowadays every...

Matching on content-type in htaccess

wordpress,.htaccess,content-type,mime

If you're on Apache 2.4.10 or later, you can use expr= as Header set Pragma "public" "expr=%{CONTENT_TYPE} =~ m#text/html#" Header set Cache-Control "public, must-revalidate, proxy-revalidate" "expr=%{CONTENT_TYPE} =~ m#text/html#" See the documentation and examples on mod_headers and expr. ...

I am using MIME::Lite::TT to send mail with perl. How to save the mail locally before sending

perl,email,mime

MIME::Lite::TT is just a preprocessor; calling MIME::Lite::TT->new returns a normal MIME::Lite object. Just save that object in whatever way you like. For example, you can print it to a filehandle: my $email = MIME::Lite::TT->new(...); $email->print(\*STDOUT); $email->send; ...

How to display multi-part MIME in a browser

html,mime

Is it possible to package the MIME sections in such a way that the browser will do the cid: replacements? No. You have to do it on the server. You could replace them with data: URIs if you want to keep everything in a single response....

What are — in email headers?

email,header,mime

These "--ID--" lines are MIME part boundaries (see https://en.wikipedia.org/wiki/MIME). They are described in https://tools.ietf.org/html/rfc2046. They are used to separate different parts of a message. According to RFC#2046 those only must be unique "enough". If you want to encapsulate an email into another one, the boundaries must not infer with each...

Uploading Picture From PhoneGap Cordova App

php,android,cordova,mime

The problem was using the wrong File Transfer plugin. Not sure where I found the other plugin or why it was used but doesn't work - <gap:plugin name="com.chanthu.evri.gcs-file-transfer" version="1.0.0" /> + <gap:plugin name="org.apache.cordova.file-trasfer" /> ...

MarkLogic doesn't recognize mime type of file

rest,nosql,mime,marklogic

Check to see what the Response Header for content type is. You Might have to set the format URL Parameter to binary. You can read the full documentation at http://docs.marklogic.com/REST/GET/v1/documents here is what the request would look like http://localhost:8010/v1/documents?uri=/pdf_demo.pdf&format=binary ...

How to use the ImapClient while it is in Idle(IdleAsync)?

imap,mime,mailkit

As Nameless One has noted, MailKit's Idle() and IdleAsync() methods take a "done" CancellationToken which can be used to end the IDLE state (when you cancel the "done" token, it will send the DONE command thus ending the IDLE state). Once you've done that, you can fetch messages and continue...

Sign/Encrypt EDIFACT document - malformed - C#

c#,email,encryption,mime,edifact

I'm not sure the issues I'm about to point out are the problem, but they might be worth looking into... First, Convert.ToBase64String(arrayToEncode); does not wrap lines as needed in MIME. What you'll need to use is this variant with Base64FormattingOptions.InsertLineBreaks. Secondly, I don't know what SignMsg() does, but make sure...

TypeError: object of type 'method' has no len() | Trying to attach file to email msg

python,email,smtp,mime

Fix in step 3, change smtpSettings.sendmail(sender, senderto, msg.as_string) to smtpSettings.sendmail(sender, senderto, msg.as_string()) because as_string is a method...

Register FileExtension with my Android App

android,file,types,mime

<action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.DEFAULT" /> <data android:host="*" android:mimeType="*/*" android:pathPattern=".*\\.myfile" android:scheme="file" /> This works!...

Perl script is not sending email

perl,smtp,mime

It means you don't have a mail server running on your machine. You need to install one and make sure it is running.

MIME base64 encode wide characters

perl,mime

As you can see in the documentation, encode_base64 accepts bytes as the argument. To get bytes from a string, encode it: use Encode; print MIME::Base64::encode_base64(encode('utf-8', "\x{2019}s text")); Don't forget to decode back on the receiving side!...

Attaching file in Python email

python,mime

So after much debugging I realized that I hadn't properly closed the file before trying to read it again for the composition of the email. I had code similar to below: with open('results.csv', "rb") as csvfile: #compose the csv file #blah #blah #blah #then I called my email function but...

Multipart email PDF attachment blank

python,email,mime

I think that you may be over complicating things. multipart/alternative is intended to be used for different representations of the same data, e.g. a plain text version of a message and the same message in HTML. In your case you can just create a multipart/mixed and attach the text and...

Add Mime Boundary

xslt,mime

Try: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" omit-xml-declaration="yes"/> <xsl:strip-space elements="*"/> <xsl:template match="/"> <xsl:text>MIME-Version: 1.0 Content-Type: multipart/Related; type="text/xml"; boundary=_MIME-Boundary --_MIME-Boundary content-type: text/xml Content-ID: BodyPart Content-Transfer-Encoding: 7bit </xsl:text> <xsl:copy-of select="."/>...

Getting rtf field from domino with java for JSON

java,json,xpages,mime,rtf

I can imagine there might be a few things involved. I suspect the first one is that replaceAll interprets the string as a regular expression. Using just replace is safer in this situation; in spite of the name, it also replaces all occurrences, but instead treats the contents as a...

Python smtplib.sendmail Mime Multipart body doesn't shown on iPhone

python,iphone,mime

I found my solution in this comment: How do I send attachments using SMTP? My first line should have been msg = MIMEMultipart('mixed') rather than 'alternative'....

Strip attachments from emails using MailKit / MimeKit

c#,email,mime

You could retrieve all MimeParts that are attachments https://github.com/jstedfast/MimeKit/blob/master/MimeKit/MimeMessage.cs#L734 and then iterate over the all Multiparts and call https://github.com/jstedfast/MimeKit/blob/master/MimeKit/Multipart.cs#L468 for the attachments to remove. The sample below makes a few assumptions about the mail e.g. there is only one Multipart some email client (Outlook) are very creative how mails are...

Where is mimetools.choose_boundary function in Python3?

python,python-3.x,httprequest,mime,multipartform-data

Well, I answer my question since no other available answer here. Yes, I got the result finally, for more info about my work around the question, the below information may help. 1. What does boundary do in an multipart/form-data request? In fact, to separate the different parts of data is...

Content encoding using MimeKit/MailKit

mime,mailkit

The 8-bit MIME transfer encoding is basically "no encoding", so any MIME data encoded with 8-bit encoding is the same as the binary representation of the data in the given charset. For instance, 'ä' represented in UTF-8 as the following sequence of bytes: 0xC3, 0xA4. When using 8-bit, your MIME...

Zip sent via email is invalid on first attempt

python,email,python-3.x,mime-types,mime

You need to close the zip file after adding the files to ensure the archive is complete. https://docs.python.org/2/library/zipfile.html#zipfile.ZipFile.close better yet use a with statement : with zipfile.ZipFile('reports.zip', 'w') as zipf: for root, dirs, files in os.walk('reports/'): for file in files: zipf.write(os.path.join(root, file)) Details As I understand them. 1st run: zipfile...

HTML-Email with inline attachments and non-inline attachments

email,mime,email-attachments

Images Yes, it is correct approach to use multipart/related content type. Here is an example (please note 'Content-Type' and 'Content-Disposition' values): Example source and detailed info Here are samples you've requested: Email with inline only attachments Email with non-inline only attachments Email with inline and non-inline attachments Sample 1: inline...

using default media player to open stream from an Ip in android using uri

android,android-intent,uri,mime,start-activity

This works for me Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.parse("http://iutv.iut.ac.ir:5657/tv2"), "video/*"); startActivity(intent); But if your problem still occurring ,take a look at here : VLC encountered an error with this media Android...

Python's `email.message.as_string` encodes some parts as base64; unclear why

python,email,character-encoding,base64,mime

Use as_bytes instead. So change your print to: print(msg.as_bytes().decode(encoding='UTF-8')) reason is in policy documentation https://docs.python.org/3.4/library/email.policy.html#module-email.policy A cte_type value of 8bit only works with BytesGenerator, not Generator, because strings cannot contain binary data. If a Generator is operating under a policy that specifies cte_type=8bit, it will act as if cte_type is...

MimeUtility.decode() doesn't work for every encoded text

java,encoding,utf-8,mime,decoding

****Solution***** (Thanks to @user_xtech007) I solve this with problem with decoding encoded parts by splitting multiple encoded parts with regex . Here is the codes of method I using private final String ENCODED_PART_REGEX_PATTERN="=\\?([^?]+)\\?([^?]+)\\?([^?]+)\\?="; private String decode(String s) { Pattern pattern=Pattern.compile(ENCODED_PART_REGEX_PATTERN); Matcher m=pattern.matcher(s); ArrayList<String> encodedParts=new ArrayList<String>(); while(m.find()) { encodedParts.add(m.group(0)); } if(encodedParts.size()>0)...

Error encoding files with MIME

java,file,base64,mime

I would try to use the wrap(...) method of Encoder/Decoder, i.e. public void encode64(File input, File output) throws IOException { FileInputStream inputStream = new FileInputStream(input); FileOutputStream outputStream = new FileOutputStream(output); OutputStream encodedStream = Base64.getEncoder().wrap(outputStream); byte buff[] = new byte[300]; int r = 0; while ((r = inputStream.read(buff)) > 0) {...

How to parse email text (bash)

bash,email,mime,quoted-printable

Okay, I'll bite. The data is quoted-printable, and we want the plain text version. So let's use Perl, which already has code for this. #!/usr/bin/perl use strict; use PerlIO::via::QuotedPrint; # Open input file through quoted-printable filter $ARGV[0] ne "" or die "No file specified"; open(IN, '<:via(QuotedPrint)', $ARGV[0]) or die "Could...

What solution for uploading video using uploadify and firefox's mp4 incompatability

firefox,uploadify,mime

FFMPEG is the solution. After uploading, use ffmpeg to convert the mp4 videos to webm (for firefox) and ogg (if you feel necessary, for compatibility with older versions of firefox) in the server.

Mail subject decoding?

email,encoding,mime

This subject is encoded in GBK, an extension of the GB2312 character set for simplified Chinese characters, used in the People's Republic of China. As defined in the RFC1342 specification, to represent non-ASCII text in Internet Message headers, you have to encode it with the MIME encoded-word syntax: encoded-word =...

Expected mime type application/xml but got text/html

java,solr,mime

I solved this by extending XMLResponseParser, overriding getContentType, and using it as response parser. protected class QESXMLResponseParser extends XMLResponseParser { public QESXMLResponseParser() { super(); } @Override public String getContentType() { return "text/xml; charset=UTF-8"; } } Then, only change your code to use the "new parser" server.setConnectionTimeout(5000); server.setParser(new QESXMLResponseParser()); server.setSoTimeout(1000); ...

Powershell Check MIME exists in IIS

powershell,iis,mime

You can check with the following: if( !((Get-WebConfiguration //staticcontent).collection | ? {$_.fileextension -eq '.xpa'}) ) { #do something } ...

Passing Special Characters into telnet Unix

unix,ksh,telnet,mime

Have you tried encoding the message first? You can do this using base64 in UTF-8 charset:- e.g. Convert: msg="£1234" To: msg="wqMxMjM0" NOTE:Try testing encoding/decoding using the online converter - https://www.base64encode.org/ Once you have encoded your text you can send the message via telnet by adding the MIME details after the...

File getting corrupted on downloading

php,file,mime

Try this one. Just mention the proper file path. Hope it works for you. ignore_user_abort(true); set_time_limit(0); // disable the time limit for this script $path = "/YOUR_FILE_PATH/"; // change the path to fit your websites document structure $dl_file = preg_replace("([^\w\s\d\-_~,;:\[\]\(\].]|[\.]{2,})", '',$_GET['download_file']); // simple file name validation $dl_file = filter_var($dl_file, FILTER_SANITIZE_URL);...

OTRS PostmasterMailbox.pl parsing/MIME type

perl,ubuntu,encoding,mime,otrs

You posted a long trace of error messages, mostly depreciation warnings of regex features from perl 5.18. The actual problem was this: open body: Invalid argument at /opt/otrs/Kernel/cpan-lib/MIME/Entity.pm line 1872. That issue was also caused by a change in Perl 5.18, and fixed in OTRS 3.2.12. You should upgrade your...

Plain text emails displayed as attachment on some email clients

perl,email,attachment,mime,plaintext

I think this is the closes thing you're going to get to an answer The documentation for MIME::Lite says this MIME::Lite is not recommended by its current maintainer. There are a number of alternatives, like Email::MIME or MIME::Entity and Email::Sender, which you should probably use instead. MIME::Lite continues to accrue...

multipart/mixed MIME creation for amazon SES on iOS

ios,email,amazon-web-services,mime

You're using the wrong Content-Type. The correct MIME type for a message with this structure is multipart/mixed, not multitype/mixed.

Using php to check MIME type of file uploaded via form

php,file-upload,mime-types,mime

finfo_file can and will return empty string and FALSE if the type is not found. Problem with mime types here is, you can't trust them either. I did this before and parsed the files with fgetcsv. Any error there and I discarded the file. This way you can be sure...

add text only version to an email template

mime,mandrill

Strongly suggest using a templating service on top of Mandrill, such as apostle or sendwithus. Makes it way easier to manage and edit html+text templates, and I believe both support your use case....

Trying to send “alternative” with MIME but it also shows up in capable mail client

java,python,email,content-type,mime

Basically, your mail is not arraged correctly. There are a few ways to arrange the parts in a MIME message so that they make sense to a mail agent. Let's start from the simple and go through to the complicated option: The simplest of all is text with a few...

Using html audio with IE: MEDIA12899: AUDIO/VIDEO: Unknown MIME type

html,internet-explorer,audio,mime

Unfortunately, its because Internet Explorer doesn't support wav-Files. In order to get cross-browser compatibility, you'll need to provide the same audio-file in several different formats. Take a look at the table on this site: https://developer.mozilla.org/en-US/docs/Web/HTML/Supported_media_formats In order to support IE, you need to add an mp3 or mp4-format. To provide...

how to embed an image in an HTML mime message with libetpan

c,mime,mailcore,mailcore2

To embed an image in an HTML mail message, you need to conform to RFC 2387. On this page, there's an example of how to build an HTML email with an embedded image. There's a related stack overflow question here: embedding image in html email Here's how to build such...