Attachments and Outlook and Outlook Express

Swift Mailer is a fantastic library for sending email with php. Discuss this library or ask any questions about it here.

Moderators: Chris Corbyn, General Moderators

Post Reply
Martinez
Forum Newbie
Posts: 4
Joined: Tue Nov 07, 2006 2:06 pm

Attachments and Outlook and Outlook Express

Post by Martinez »

First of all thanks for the great library...

I am having a weird problem. I am sending emails with attachments.
(I used your example code as a base).

The attachments are not recognized by outlook or outlook express.

I bcc to myself (Mac Mail client) and I see the attachment fine.

Any thoughts on this...?

I let swift set the mime type (octet-stream) :

Code: Select all

$mailer = new Swift(new Swift_Connection_SMTP('mail.xxx.org'));
if ($mailer->isConnected())  {
  $mailer->addAttachment(file_get_contents($file), $this->current_doc);
  if ($this->test_email != '')
  {  
      $mailer->send(
                '<' . $this->test_email . '>',
                '"' . $this->name . ' Ski Report" <dds@xxx.org>',
                'Ski Report'
          ); 
     $mailer->close();
   }
Again I see the attachments via Mac Mail client and online IMAP clients..

Thanks again
(And sorry about posting in the wrong area...)
Martinez
Forum Newbie
Posts: 4
Joined: Tue Nov 07, 2006 2:06 pm

More information...

Post by Martinez »

Some more information I have gleamed from testing....
  • 1. It happens for various document types.... pdf / word / xls
    2. Outlook or Outlook express seems to recognize the attachement to download it. (...progress bar shows activity..)
    3. When email finally displays, I recieve a blank body...
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Do you have gpc_magic_quotes turned on perhaps?

Try:

Code: Select all

stripslashes(file_get_contents($file))
Also, what does the current_doc property actually look like? If you send me a copy of such an email ( chris@w3style.co.uk ) or copy the email source code upon receipt here I'll have a closer look.

The correct mime type of MS Word is "application/msword" if you want to set it directly ;)
Martinez
Forum Newbie
Posts: 4
Joined: Tue Nov 07, 2006 2:06 pm

Aha... Found the solution

Post by Martinez »

Solution is I neglected to add a body element..

Once I added:

$mailer->addPart('xxx attached....');

It worked like a charm...

Code: Select all

$mailer = new Swift(new Swift_Connection_SMTP('mail.xxx.org'));
if ($mailer->isConnected())  {
  $mailer->addAttachment(file_get_contents($file), $this->current_doc);
  $mailer->addPart('Ski Report attached');
  if ($this->test_email != '')
  { 
      $mailer->send(
                '<' . $this->test_email . '>',
                '"' . $this->name . ' Ski Report" <dds@xxx.org>',
                'Ski Report'
          );
     $mailer->close();
   }
}

........
Thanks again...

And I will be contributing to your mac mini fund....
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

I'm surprised it didn't work without the body. Structurally the email would be fine without the body since the boundaries are all there and in the correct places. Glad you got it working anyway.

Thank you so much for the donation. Received this morning. Extremely generous and much appreciated :)
jacknirons
Forum Newbie
Posts: 6
Joined: Wed Aug 27, 2003 5:41 am

cut off filenames on outlook

Post by jacknirons »

Hi there ;)
so, i have another outlook problem and no solution. the situation is, i have long filenames in my attached files. they will recognized by thunderbird very well. but on outlook and outlook express there seems to be a problem. because, they always add a txt-extension to the attached files.
I was looking around sometime and found a "old" thunderbird bugreport, but with the same problem (http://kb.mozillazine.org/Attachments_renamed). The solution was, that the specific thunderbrid client supports a older standard for file attachments (RFC2047), the working a actuall (RFC2231).
So, i was tracking the swift code a little bit and seen that the libs are using a newer standard.

So, what was my question. ah, right. has anyone a working solution for cutoff filenames (after ~60 chars) on outlook ? ;)
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: cut off filenames on outlook

Post by Chris Corbyn »

jacknirons wrote:Hi there ;)
so, i have another outlook problem and no solution. the situation is, i have long filenames in my attached files. they will recognized by thunderbird very well. but on outlook and outlook express there seems to be a problem. because, they always add a txt-extension to the attached files.
I was looking around sometime and found a "old" thunderbird bugreport, but with the same problem (http://kb.mozillazine.org/Attachments_renamed). The solution was, that the specific thunderbrid client supports a older standard for file attachments (RFC2047), the working a actuall (RFC2231).
So, i was tracking the swift code a little bit and seen that the libs are using a newer standard.

So, what was my question. ah, right. has anyone a working solution for cutoff filenames (after ~60 chars) on outlook ? ;)
Swift follows RFC2047 for long filenames. What version of Swift are you using? Do you have an example filename you are able to send me?

EDIT | Oops, sorry I do follow RFC2231. The encoding method comes is based on RFC2047. Been so long since I touched that code :oops:
jacknirons
Forum Newbie
Posts: 6
Joined: Wed Aug 27, 2003 5:41 am

Post by jacknirons »

Hey,
i'm sorry, but the name of the files are a strict internal thing. but you can take just every filename with 60 or more characters (with and without characters like whitespaces, [], () or points.

(i'm using outlook 2007 and a older outlook express version by a customer)

to this moment, we where using the 3.2.1 (php5) version of swift . in the last couple of minutes, i was updating to 3.3.1 (php5). same result :/
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

jacknirons wrote:Hey,
i'm sorry, but the name of the files are a strict internal thing. but you can take just every filename with 60 or more characters (with and without characters like whitespaces, [], () or points.

(i'm using outlook 2007 and a older outlook express version by a customer)

to this moment, we where using the 3.2.1 (php5) version of swift . in the last couple of minutes, i was updating to 3.3.1 (php5). same result :/
If you were to send the same filename through Thunderbird does the filename arrive in-tact? I suspect MS is choking on the RFC2231 syntax for:

filename*0*="......"
filename*1*="...." etc etc etc
jacknirons
Forum Newbie
Posts: 6
Joined: Wed Aug 27, 2003 5:41 am

Post by jacknirons »

right right. i was sending examples (with the same file) through different other clients. thunderbird 2.0.0.6, gmail and a horde-clientinterface.
they arive all in tact, with headers like:

name="some_realy_large_filename_that_will_arrive_in_full_length_at_the_client.csv"
filename="some_realy_large_filename_that_will_arrive_in_full_length_at_the_client.csv"

emails, created and delivered with swift, as you surely know, contains:

name*0="some_realy_large_filename_that_will_arrive_";
name*1="in_full_length_at_the_client.csv"
filename*0="some_realy_large_filename_that_will_arrive_";
filename*1="in_full_length_at_the_client.csv"
jacknirons
Forum Newbie
Posts: 6
Joined: Wed Aug 27, 2003 5:41 am

Post by jacknirons »

so, eh, is there possible a chance to easily switch between this standards!? ;)
jacknirons
Forum Newbie
Posts: 6
Joined: Wed Aug 27, 2003 5:41 am

Post by jacknirons »

eh, guys is it possible that you have replace the rfc204x support with a newer one?
because, i find comments and function that refeence to 204x or (fe: Swift_Message_Encoder::rfc2047Encode())

could you please deliver that older (possible removed) codepart, before i have to rewrite this part for myself? ;)
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Please do not bump threads. Your question will be answered when someone has an answer. Our forum rules clearly state to not bump a thread for 24 hours after posting. Thank you.
afwt
Forum Newbie
Posts: 15
Joined: Fri Sep 21, 2007 2:53 pm

Post by afwt »

Did anyone else had this same problem? No matter what client I try to send an email to, I get attachment names scrambled. And whatever mailer I use, no one is rewriting the header in the same way as SM.... :-(
Post Reply