LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-08-2004, 08:33 PM   #1
gothgeek84
Member
 
Registered: Feb 2004
Location: USA
Distribution: Ubuntu 7.04, Experimenting with others
Posts: 46

Rep: Reputation: 15
Receiving Emails through web server? (PHP)


I'm looking for a way to "intercept" emails sent to my server...I'm not sure quite how to describe what I'm looking for. Basically, I'm working in PHP, and I want to create a completely web-based e-mail service. This means that I don't want to use some sort of "external" servers and such.

I need to figure out how, when people send e-mails from their client to an address on my server (aka someone@mysite.com), I want my webserver (meaning a script on that server) to catch that request so I can deal with it.

Oh, and I'd like it to be cross-platform. (Honestly, I want it to all work in PHP).

Can anyone give me a little help here? I don't know anything about email, that's my biggest problem; once I get the e-mails, I can deal with it all from there Even just something on basic email theory would help - it doesn't have to be PHP related (that's why I'm posting it here, rather than a PHP-centric forum).

Thanks in advance,
Doug Burkhalter
 
Old 09-08-2004, 09:57 PM   #2
CroMagnon
Member
 
Registered: Sep 2004
Location: New Zealand
Distribution: Debian
Posts: 900

Rep: Reputation: 33
Did I read this right? You want to create an entire mail server setup in PHP? Including receiving emails and so forth?

It could theoretically be done, although you'd have to write external applications in PHP and set them up to answer on the right ports.

The most important question is how do you receive your email now? Do you use fetchmail to get it from your ISP, or is your machine the MX for your domain?

I think it would be better to set up an external mail-fetching-and-storing system, and just use PHP to talk to that with the IMAP module. If you go about trying to re-create SMTP, POP3 and IMAP protocol handlers (not to mention implementing RFC822 and friends), you're going to be fixing it for the rest of your life.
 
Old 09-08-2004, 10:08 PM   #3
gothgeek84
Member
 
Registered: Feb 2004
Location: USA
Distribution: Ubuntu 7.04, Experimenting with others
Posts: 46

Original Poster
Rep: Reputation: 15
Hmm, well, that's pretty close to what I want. I wouldn't necessarily consider it a "server", but a whole email "application".

I'm not looking to do this to "replace" anything I have now, I'm basically wanting to do it just to see if it can be done.

I'm hoping to find a way to setup a completely POP3/IMAP-free (and possibly SMTP-free, depending on how PHP handles it) email solution, similar to how Yahoo! Mail or Hotmail works.

Well, I know nothing about e-mail, or basically any forms of server communications. Basically, the most important thing I need to know is how the server knows it's getting an email and all that, so I can see about grabbing that and using it how I need.

I know I sound like a , and in the case of server communications, I guess I am.
 
Old 09-08-2004, 10:28 PM   #4
CroMagnon
Member
 
Registered: Sep 2004
Location: New Zealand
Distribution: Debian
Posts: 900

Rep: Reputation: 33
*phew*

That's ok then What you want to look at is the IMAP module of PHP (which, confusingly, also handles POP3 through functions named imap_*). Also, the mail module handles sending email outwards. The mailparse module also has some useful functions for interpreting what the server will give you.

I would recommend setting up an IMAP server to talk to, as this gives you more flexibility for things like searching through email, creating folders, and also handles the storage side of things nicely. Also, for hints and tips, you might like to install one of the existing PHP mail systems. If you have some more specific questions about email, post them here

(That 'newbie' animation is madness. MADNESS!)
 
Old 09-10-2004, 12:40 AM   #5
gothgeek84
Member
 
Registered: Feb 2004
Location: USA
Distribution: Ubuntu 7.04, Experimenting with others
Posts: 46

Original Poster
Rep: Reputation: 15
Oops, I think I said something wrong. I'm looking to avoid routing it through an IMAP or POP3 server. I'm not really looking to setup an "email server", I'm looking for a way to avoid one altogether (Although I suppose it could be considered a server...).

Basically, I'm hoping to develop a standalone webmail service, that doesn't need anything externally. All I really need to figure out is how to "grab" the emails when they're sent to my domain, basically reroute them to the Web server so I can have my script interpret them and put the info into a database.

Is this even possible? That's the big question. If someone can point me at something about how emails work, how the server knows when it's got an email, etc, that would be perfect (is it by port, or protocol, or what?)

I guess this is all really confusing, and honestly I'm not exactly sure what I want, muchless how to convey it...basically, I want to setup a script on the web server to read emails....I might have to actually build a simple mail server to redirect, but I'm hoping it won't come to that; ideally, I want it all in PHP.
 
Old 09-10-2004, 12:59 AM   #6
CroMagnon
Member
 
Registered: Sep 2004
Location: New Zealand
Distribution: Debian
Posts: 900

Rep: Reputation: 33
OK, we're back to how you currently get your email. There are two methods for this - one is direct SMTP, where you have your server set up to receive SMTP directly from the net (it is one of the MXs for a domain name, or your ISP handles it and passes on everything via SMTP to you). For this, you will need an SMTP server. The other way you might get your mail is have your ISP receive it as the domain's MX, and you pick it up via POP3 or IMAP. Mail is usually delivered locally on your system by a program like sendmail, qmail, postfix or courier, and usually does this via SMTP (albeit internally). For example, fetchmail grabs email via POP3 according to your configuration, and then 'sends' it to port 25 on your local system. In order for your system to get email, you are going to have to speak at least one of POP3, IMAP or SMTP. Otherwise, you need to let other programs handle it, and read the email files from a user's mail store.

So realistically, I think you are going to have to build a working mail server. You might be able to get away without a fully functional one, but how you go about that is determined by how you get your mail now (and whether you want to support other configurations later). By writing a PHP mail client instead, you get all the functionality you will need to read and write emails, but without all the hassle of learning too much about email. Is there something you need to do that can't be done with existing mail server software?
 
Old 09-10-2004, 05:36 AM   #7
gothgeek84
Member
 
Registered: Feb 2004
Location: USA
Distribution: Ubuntu 7.04, Experimenting with others
Posts: 46

Original Poster
Rep: Reputation: 15
Hmm, I was afraid of that. I suppose my idea was a bit out there, oh well. Thanks for your help, though...I might build this at some point, but considering I would have to venture outside of PHP, I'm not so sure I want to do it.

Hmm, I could always do it to work with another server, but I dunno. Thanks for the assistance, though.
 
Old 09-16-2004, 06:11 AM   #8
Kanon
Member
 
Registered: Sep 2004
Location: Norge
Distribution: Debian
Posts: 116

Rep: Reputation: 15
I found this HOWTO: http://www.tldp.org/LDP/abs/html/con...tml#MAILFORMAT

Dont know it this will help you
 
Old 09-16-2004, 11:25 AM   #9
gothgeek84
Member
 
Registered: Feb 2004
Location: USA
Distribution: Ubuntu 7.04, Experimenting with others
Posts: 46

Original Poster
Rep: Reputation: 15
Well, it might be useful along the line, but the first thing I'd need to do would be to find out how to get the mail...which seems impossible, in PHP at least.
 
Old 09-16-2004, 05:08 PM   #10
CroMagnon
Member
 
Registered: Sep 2004
Location: New Zealand
Distribution: Debian
Posts: 900

Rep: Reputation: 33
It's not impossible in PHP. It's possible to:
a) Get your mail via POP3 if your ISP provides it to you this way. For example, my ISP sends all email for my domain to a single POP box, and I use fetchmail and postfix to send it to various user accounts. I could replace fetchmail and the mail storage side with a web-based interface (though it would be more awkward to convince a PHP script to run periodically).
b) Write an SMTP server in PHP, but it would not run via Apache - i.e you would have to build the program standalone (and spend the rest of your life solving problems that others have solved many times).

I honestly don't understand the point of replacing a fully functional mail system with a slower version written in PHP.
 
Old 09-16-2004, 08:38 PM   #11
gothgeek84
Member
 
Registered: Feb 2004
Location: USA
Distribution: Ubuntu 7.04, Experimenting with others
Posts: 46

Original Poster
Rep: Reputation: 15
Well, see, I'm looking for a way entirely in PHP...no rerouting, no standalone programs...just PHP scripts. That may not be impossible, but it seems to be close.


Quote:
Originally posted by CroMagnon
I honestly don't understand the point of replacing a fully functional mail system with a slower version written in PHP.
Cuz I can. (Well, no, I guess I can't...) Honestly, I figured it might be a nice idea to see if there was a way. Heck, it might be a bit slower, but the point is it's all web based; it would let people just drop in an email system for their sites...no extra programs, no special access, just a script.
 
Old 09-17-2004, 01:10 AM   #12
DanTheKiwi
LQ Newbie
 
Registered: Aug 2004
Location: Sydney, Australia
Distribution: FreeBSD, Fedora Core 2
Posts: 20

Rep: Reputation: 0
alot of places do this already a few free web based email places allow you to check a POP account also and sending mail though it is simply a matter of using that address as the reply-to.
 
Old 01-16-2005, 03:02 PM   #13
Kanon
Member
 
Registered: Sep 2004
Location: Norge
Distribution: Debian
Posts: 116

Rep: Reputation: 15
Quote:
Originally posted by gothgeek84
Well, see, I'm looking for a way entirely in PHP...no rerouting, no standalone programs...just PHP scripts. That may not be impossible, but it seems to be close.




Cuz I can. (Well, no, I guess I can't...) Honestly, I figured it might be a nice idea to see if there was a way. Heck, it might be a bit slower, but the point is it's all web based; it would let people just drop in an email system for their sites...no extra programs, no special access, just a script.
There is a way to send mail from php. Click on any user here from the profile you can send them mail. But ofcoz they cant read it in here since it goes to their "mail box".

Any how, if you find something; I want it too!!!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Not receiving notification emails Nylex LQ Suggestions & Feedback 2 09-07-2005 08:49 AM
Receiving multiple messages with a php Server mrobertson Programming 30 06-13-2005 07:11 AM
Receiving Emails as a server deleted_user_01 Linux - Newbie 14 02-17-2005 09:15 AM
not receiving emails aroop Linux - Networking 1 09-30-2004 05:43 PM
not receiving emails from server eliboone Red Hat 9 08-29-2003 11:47 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:10 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration