6

Currently I'm writing a web interface which is full of data. I would like to export this data as an e-mail template, so you can edit the e-mail afterwards. Is there a format such as *.oft, which can be read by all email programs?

I know that there is such a function in HTML (<a href="mailto:[...]">). Since the e-mail text is very long and I want to attach files, this doesn't seems to be a good solution.

Can someone help me?

lanzz
  • 42,060
  • 10
  • 89
  • 98
Tobias Bambullis
  • 736
  • 5
  • 17
  • 45
  • There isn't really any email template file format as emails are designed using HTML and CSS. Couldn't you just send the mail to the user and have the user make a copys of the email when he/she needs to use it? If you need to attach a file to the email you're sending, take a look at [PEAR mail](http://pear.php.net/package/Mail/redirected). – fimas Nov 18 '12 at 17:26
  • if nobody knows an answer to this problem, I have to, I think :-( – Tobias Bambullis Nov 18 '12 at 17:34
  • Microsoft Outlook can use Word documents(.docx) to create email templates, but you cannot count on that other email clients to do this. HTML and CSS is the safe way to go if you want users of different clients to be able to use your templates. – fimas Nov 18 '12 at 17:48

4 Answers4

2

There's no such format as you're looking for. The internet engineers who design email protocols and format concern themselves with what goes out over the network, but not with what's internal to the machine. Email is highly interoperable when sending and receiving messages as a result, but there's no analogous standards body for internal API's. Sometimes there are de facto standards that arise from a imitating the behavior of popular piece of software, but that hasn't happened for the email feature you're looking for.

eh9
  • 7,340
  • 20
  • 43
  • Unfortunately, it seems like you have it right. I was hoping that there is a standard for email templates ... Too bad. – Tobias Bambullis Nov 26 '12 at 12:00
  • There's any number of reasons why standard data formats for application software would be useful, but there's no entity that has that mandate. The W3C does related work, but even that's still principally oriented at data that crosses the internet. – eh9 Nov 26 '12 at 23:41
0

Maybe you mean .EML files? I remember that this file can be opened with nearly all e-mail clients such as Outlook, Thunderbird etc.

www
  • 586
  • 1
  • 14
  • 29
  • But eml is not a template. It is the email itself. And users will need to hit reply or forward to make it suitable. – iWantSimpleLife Nov 23 '12 at 01:06
  • i had found [a thread](http://stackoverflow.com/questions/7916318/open-eml-files-in-compose-mode-in-outlook-2010) where you can open EMLs in draft mode and send them (functioning basically as a template)... but i find twice as many saying you can't... it definitely feels more like a hack than an intended use, but it's possible if you can get the hack to work in your email client. – John Proestakes Dec 03 '16 at 13:19
0

As far as I can tell you can go one of two ways:

1 - Use a prebuilt solution such as the one by these guys at postageapp.com their API looks pretty simple and does everything you want to achieve.

2 - More time consuming, but you can create your own templete using PHP. I would go for something along these lines. This is a very simple way of doing it. You could write your own CSS in the head and go nuts. Just remember that tables are king when it comes to HTML email :) Once the template has been written, you could just pass through the $content to fill it....

sender.php

<?php

        $email = "Hello, \n";
        $email.= "Very <strong>impressed</strong> with your email! \n\n";
        $email.= "Faithfully\n";
        $email.= "Mr Example\n";

        $to = "me@me.me"; // <-- Set this as yours for testing...

        $from = "someone@nice.me";
        $subject = "An email";
        $headers = "From: Someone nice <" . $from . ">\r\n";
        $headers .= "Reply-To: ". $from . "\r\n";
        $headers .= "MIME-Version: 1.0\r\n";
        $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
        $message = '<html><body>';
        $message .= nl2br($email); // <---- if your email contains newline characters - it will convert them to <br />
        $message .= '<br /><a href="http://www.example.com" target="_blank">www.example.com</a>';   
        $message .= "</body></html>";
        mail($to, $subject, $message, $headers);    
            // ADD LOTS OF PROTECTION IF NOT HARD CODING :)
?>

To extend this - if you for example use Gmail, then you could use Google's SMTP to send it - so that the email wouldn't say 'Sent on behalf of'.

Chris
  • 5,516
  • 1
  • 26
  • 30
0

Just create a email using HTML without CSS. Any data or binary can be passed through PHP and then emailed to the recipient.

To get you started, Create a file using fopen();. PHP has other functions that would allow you to edit, open, search&replace and even convert a file to a format of your choice. This is equivalent to a .oft file if not better, because all emails are be sent in text or a html equivalent regardless of the email client.

If you'd would like some more info on how to create this, let me know.