storing emails

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
gosi
Forum Newbie
Posts: 3
Joined: Thu Sep 13, 2007 8:30 am

storing emails

Post by gosi »

Hi there,

I have read through the forum a bit and found this one:
viewtopic.php?t=66641

Anyhow, let me explain the problem: I create a message and send this one out via swiftmailer,
which works great already but now: I have to move that message into a IMAP folder / database.

So my question is: is there a way to make swiftmailer output the complete created message,
including mime, attachments etc.?


Thanks for your help :)
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: storing emails

Post by Chris Corbyn »

gosi wrote:Hi there,

I have read through the forum a bit and found this one:
viewtopic.php?t=66641

Anyhow, let me explain the problem: I create a message and send this one out via swiftmailer,
which works great already but now: I have to move that message into a IMAP folder / database.

So my question is: is there a way to make swiftmailer output the complete created message,
including mime, attachments etc.?


Thanks for your help :)
I'd probably suggest using the IMAP functions for this. if you want to see the source code that Swift is about to send you can (almost*) see it with this:

Code: Select all

$stream =& $message->build();
echo $stream->readFull();
* I say almost because the addressing headers (To:, Cc:, Bcc:, From:, Reply-To:) are added during sending.
gosi
Forum Newbie
Posts: 3
Joined: Thu Sep 13, 2007 8:30 am

Post by gosi »

thanks for your help, I will try that :)
gosi
Forum Newbie
Posts: 3
Joined: Thu Sep 13, 2007 8:30 am

Post by gosi »

Hi!

I switched the whole thing to swift mail now and well it works great.
For adding the to, from, cc, and stuff I use a simple str_replace and
this way the email becomes complete before I push it in via IMAP.

Well, thanks again and I just donated some money .. :)
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

gosi wrote:Hi!

I switched the whole thing to swift mail now and well it works great.
For adding the to, from, cc, and stuff I use a simple str_replace and
this way the email becomes complete before I push it in via IMAP.

Well, thanks again and I just donated some money .. :)
Ooohh, :) thanks for the donation, much appreciated.

You may get better results using:

$message->setTo()
$message->setFrom()
$message->setReplyTo()

etc etc

The reason I say that is because those methods will deal with things in the RFCs which a simple str_replace() may not do. Sorry, I should have mentioned those methods before. It's these methods which Swift uses when it sends the email.
Post Reply