how to remove attachment

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
ksmj
Forum Newbie
Posts: 2
Joined: Sun Mar 23, 2008 2:10 am

how to remove attachment

Post by ksmj »

I have a program to run through a database data which has email address and a filename for the email address.

The task is to attach the file as specified in the filename to the email address.

I am having problem with my program where by it attached 1 file for the first email, 2 files for the 2nd and 3 files for the 3rd. Obviously, the problem comes from the fact that files kept on being added to the message but the old file for previous email wasn't removed.

So my question is, how do i remove the other files that I attached earlier for other emails.
I have a loop to run through all email address


prepare message
loop while still have email address to send
attach file for this email
send out email
end

what i need is to remove the attachment after i sent out the email, but how do i achieve that?



Thanks in advance



Kelvin
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: how to remove attachment

Post by Chris Corbyn »

Code: Select all

$id = $message->attach($attachment);
$message->detach($id);
EDIT | Changed code, I got mixed up and showed some v4 code
ksmj
Forum Newbie
Posts: 2
Joined: Sun Mar 23, 2008 2:10 am

Re: how to remove attachment

Post by ksmj »

thanks mate, some how i missed that function when I search through the doc.
Post Reply