473,396 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

PHP & IMAP forwarding & attachments


Hi, I'm looking to setup an email system that will log into a catchall
account, read to addresses and forward them to a different email address
stored in a MySQL table. I may also allow the users to store these emails in
their own accounts at a future date.

I've got the IMAP checking etc etc working just fine. However this will be
more troublesome if someone includes an attachment. Firstly, the
imap_body($mbox,$num) chucks out loads of gobbledygook[1] at the moment. I
guess this is the real code behind, but how should I forward that? Also, can
I reject any attachments easily?

Thanks

Nick

[1]
/9j/4AAQSkZJRgABAgEBLAEsAAD/7QlMUGhvdG9zaG9wIDMuMAA4QklNA+0KUmVzb2x1dGlvbgAA

AAAQASwAAAABAAEBLAAAAAEAAThCSU0EDRhGWCBHbG9iYWwgTG lnaHRpbmcgQW5nbGUAAAAABAAA

AHg4QklNBBkSRlggR2xvYmFsIEFsdGl0dWRlAAAAAAQAAAAeOE JJTQPzC1ByaW50IEZsYWdzAAAA

CQAAAAAAAAAAAQA4QklNBAoOQ29weXJpZ2h0IEZsYWcAAAAAAQ AAOEJJTScQFEphcGFuZXNlIFBy

aW50IEZsYWdzAAAAAAoAAQAAAAAAAAACOEJJTQP1F0NvbG9yIE hhbGZ0b25lIFNldHRpbmdzAAAA

SAAvZmYAAQBsZmYABgAAAAAAAQAvZmYAAQChmZoABgAAAAAAAQ AyAAAAAQBaAAAABgAAAAAAAQA1

AAAAAQAtAAAABgAAAAAAAThCSU0D+BdDb2xvciBUcmFuc2Zlci BTZXR0aW5ncwAAAHAAAP//

AAAAAQAtAAAABgAAAAAAAThCSU0D+////
Aug 31 '05 #1
4 9734
elyob wrote:
I've got the IMAP checking etc etc working just fine. However this
will be more troublesome if someone includes an attachment. Firstly,
the imap_body($mbox,$num) chucks out loads of gobbledygook[1] at the
moment. I guess this is the real code behind, but how should I
forward that?
You should forward it as is, because it's base64 encoded binary data.
Also, can I reject any attachments easily?


You can analyse each part of the message with the imap_fetchstructure
function, after which it's just a matter of selecting the part you want to
use in the forwarded message with the imap_fetchbody function.
JW


Aug 31 '05 #2

"Janwillem Borleffs" <jw@jwscripts.com> wrote in message
news:43**********************@news.euronet.nl...
elyob wrote:
I've got the IMAP checking etc etc working just fine. However this
will be more troublesome if someone includes an attachment. Firstly,
the imap_body($mbox,$num) chucks out loads of gobbledygook[1] at the
moment. I guess this is the real code behind, but how should I
forward that?


You should forward it as is, because it's base64 encoded binary data.


Out of interest, what method would you use to forward it? I would like it to
look like it has come from the originator and not showing as forwarded. I
was doing this ..

$body = imap_body($mbox,$i);
imap_mail($toaddress, $subject, $body, 'From: in**@example.com');

.... which doesn't work.

Thanks
Sep 1 '05 #3
elyob wrote:
Out of interest, what method would you use to forward it? I would
like it to look like it has come from the originator and not showing
as forwarded. I was doing this ..

$body = imap_body($mbox,$i);
imap_mail($toaddress, $subject, $body, 'From: in**@example.com');

... which doesn't work.


What you really want is to bounce the message rather then forwarding it.

For this, the function is correct but the header isn't. Use headers like the
following:

$headers = "ReSent-Date: " . strftime("%b %d %Y %H:%M:%S") . "\r\n";
$headers .= "Resent-From: <your email address>\r\n";
$headers .= "Resent-To: <recepient email>\r\n";
$headers .= "ReSent-Subject: <original subject>";

Tip: Look at the source of the IMP package from the Horde project
(http://www.horde.org/) to see how they took care of this.
JW

Sep 1 '05 #4

"Janwillem Borleffs" <jw@jwscripts.com> wrote in message
news:43**********************@news.euronet.nl...
elyob wrote:
Out of interest, what method would you use to forward it? I would
like it to look like it has come from the originator and not showing
as forwarded. I was doing this ..

$body = imap_body($mbox,$i);
imap_mail($toaddress, $subject, $body, 'From: in**@example.com');

... which doesn't work.


What you really want is to bounce the message rather then forwarding it.

For this, the function is correct but the header isn't. Use headers like
the following:

$headers = "ReSent-Date: " . strftime("%b %d %Y %H:%M:%S") . "\r\n";
$headers .= "Resent-From: <your email address>\r\n";
$headers .= "Resent-To: <recepient email>\r\n";
$headers .= "ReSent-Subject: <original subject>";

Tip: Look at the source of the IMP package from the Horde project
(http://www.horde.org/) to see how they took care of this.


Thanks, that's a very lateral thinking way of doing it. I like it! I'll play
with it next week.

Many thanks, again!

Nick
Sep 2 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Francesco Moi | last post by:
Hello. I designed a form to edit some DataBase's fields. But some of these fields contain '&lt;' and '&gt;' characters. And these characters are '<' and '>' in HTML. So if want to edit these...
11
by: BoonHead, The Lost Philosopher | last post by:
I think the .NET framework is great! It's nice, clean and logical; in contradiction to the old Microsoft. It only saddens me that the new Microsoft still doesn't under stand there own...
0
by: James Thurley | last post by:
I'm creating an XmlDocument manually, adding content using the Xml classes such as XmlElement and XmlText, and I then write it out as as "text/xml" to the HttpResponse.Output TextWriter object...
4
by: Luklrc | last post by:
Hi, I'm having to create a querysting with javascript. My problem is that javscript turns the "&" characher into "&amp;" when it gets used as a querystring in the url EG: ...
3
by: Menu Chen | last post by:
我用LISTVIEW控件的时候,想限制用户对控件列大小的调节 但是找遍了LISTVIEW的属性,没有实现该功能的 另外,如果实在不能限制用户对列大小的调节的话,起码不要显示水平滚动 条,因为那会比较难看,可以吗?
2
by: Thief_ | last post by:
I need to monitor POP3 & IMAP servers for new emails. Ideally my app needs to sit in the system tray. Has anyone done this before? -- | +-- Thief_ | VB.NET 2003
2
by: radhakrishnanrs | last post by:
Hi all, Here, a xml file is not in proper format. I need to replace the "&" symbol to "&amp;" under the attributes. Find below the sample xml file for glance: <root> <child1> <child2...
3
by: Roger F | last post by:
Help Please When I insert code into my database ie. This & That I see it is the same in the data base but when I go to view it, it as changed into. This &amp; That What is happening, rather a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.