Force file . EML open directly in e-mail client

Asked

Viewed 139 times

0

Thunderbird allows a 'imagem' email be saved in a file, this file comes in format '.EML', and on my system, users load this file into the system along with what they are doing related to particular company.

Mechanisms like Steam, Mega, and torrent sites ask the user if they want to run a specific program or a standard program for the file type.

I believe it is something simple and with HTML even, but I could not find how to do it.

How to open a direct ext . EML in the email client ?

NOTE: If it is an intranet system there is no problem in being invasive.

2 answers

1


This is just an additional to the answer. A cool tool for this would be the http://filext.com, although having a Unix-based or Linux-based system is possible to do this via the command line.

Assuming you want to detect other types of mime-type, in Ubuntu there is the command file, example of use:

file --mime-type arquivo.eml

In PHP (since it was the solution proposed in your reply) you can use the fileinfo, something like:

function mimeType($file)
{
    $mimetype = false;

    if (class_exists('finfo')) {//PHP5.4+
        $finfo     = finfo_open(FILEINFO_MIME_TYPE);
        $mimetype  = finfo_file($finfo, $file);
        finfo_close($finfo);
    } else if (function_exists('mime_content_type')) {//php5.3 ou inferiror
        $mimetype = mime_content_type($file);
    }

    return $mimetype;
}

The use would be something like:

$mime = mimeType($file);

if (!$mime) {
    die('Formato desconhecido');
} else {
    $filename = urlencode(basename($file));

    header("Content-Disposition: attachment; filename=$filename");
    header("Cache-Control: public");
    header("Content-Description: File Transfer");
    header("Content-Type: $mime");
}

Note that I coded the filename= should contain only the name (not sure if you passed the full name) it would be interesting to go through basename($file) to obtain only the same name.

It is also necessary to encode, if you have spacing between the characters of the file name urlencode(basename($filename)).

0

Solution was only with headers even, it didn’t work just because it pointed out the standard program by 'content-type' be set wrong, with 'message/rfc822' worked correctly (force the download and suggest the program, it is already enough):

header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=$file");
header("Content-Type: message/rfc822");
header("Content-Transfer-Encoding: binary");
readfile($file);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.