[FX.php List] Email attachments in PHP

Andrew Denman adenman at tmea.org
Thu May 29 15:25:50 MDT 2008


If all you're doing is creating a text file with xml the file functions are
all you need:
http://us3.php.net/manual/en/function.fwrite.php

(from the page linked above:)
$fp = fopen('\path\to\data.txt', 'w');
$text = '<xml>\n';
...
$text .= '</xml>\n';
fwrite($fp, $text);
fclose($fp);

Even better, if you have PHP5 you just need one function:
http://us3.php.net/manual/en/function.file-put-contents.php

$text = '<xml>\n';
...
$text .= '</xml>\n';
$fp = file_put_contents('\path\to\data.txt', $text);

And then use the swiftmailer code for attachments, using the
'\path\to\data.txt' as your file. I've not used it so I can't provide an
example here.

Andrew Denman


-----Original Message-----
From: fx.php_list-bounces at mail.iviking.org
[mailto:fx.php_list-bounces at mail.iviking.org] On Behalf Of Dale Bengston
Sent: Thursday, May 29, 2008 2:12 PM
To: FX.php Discussion List
Subject: Re: [FX.php List] Email attachments in PHP

I know when we were testing it, we were able to attach to it. I don't  
think it would be any big different to create, say, a PDF attachment  
on the fly and then attach it to an email....

Dale

On May 29, 2008, at 11:12 AM, Bob Patin wrote:

> Dale,
>
> Have you actually created an attachment on the fly?
>
> I've used Swift Mailer, but not for attachments...
>
> Thanks,
>
> BP
>
>
> On May 28, 2008, at 9:20 PM, Dale Bengston wrote:
>
>> I second Swift Mailer. We have deployed it recently and it works  
>> great!
>>
>> Dale
>
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list

_______________________________________________
FX.php_List mailing list
FX.php_List at mail.iviking.org
http://www.iviking.org/mailman/listinfo/fx.php_list



More information about the FX.php_List mailing list