Jump to content

get mail from mail server and process it.


hanwei

Recommended Posts

hi, sorry to bother again.

can anyone give me some example on how to get mail from a mail server and process it.

For example, a user send an email to the address hanwei@test.com. The database will get the email from the mail server(hanwei@test.com), and process it.

normally the basic format of an email is,
To:
From:
Header:
Message:


So if i want my database automatically insert the values from the mail to my database, how am i suppose to do it?

(mail) > (database)
From > Client Name
Header > Problem
Message > Problem Description

so can anyone give me some example or teach me on how to do it?
thanks..
Link to comment
Share on other sites

To do this you are going to have to edit it cause i dont know what your trying to do but the basic background you want to use is:
[code]
<?php
$message = "";
$_from = "";
$to      = $row['email'];
$subject = "";
$headers = "From: " . $_from . "\r\n";

mail($to, $subject, $message, $headers);
?>
[/code]
Link to comment
Share on other sites

oh.. for example, if i'm the user, i send a email to this address hanwei@test.com, using hotmail, google, or yahoo.

this is the content of my mail:

To: hanwei@test.com
From: hanwei
Header: trouble ticket
Message : i have a trouble ticket


so when hanwei@test.com received this email, the database will grab this email and process it such that,

values in From will go into table column called ClientName
values in Header will go into table column called Problem
values in Message will go into table column called ProblemDesc

its like the database will automatically grab the email from hanwei@test.com and process it, automatically insert the values in From,Header and Message into table column ClientName,Problem and ProblemDesc respectively...

*sorry for my poor english..
Link to comment
Share on other sites

That script will go ahead and process it. do you want it to put the information that people send into the database, so you can look at it. or something like that. Please explain what you want to accomplish with putting it in the database. BTW Your english is fine.
Link to comment
Share on other sites

Hi,

i want the database to automatically insert the values( From, Header, Message) into my table. the table consist of column called ClientName, Problem and problemDesc. i want the script to insert From, Header and Message into column clientName, Problem and problemDesc respecitively. i have already created a script whereby it will print out all the tickets created. so if my database grab an email from hanwei@test.com, it will create a new ticket.

it acts like a page similar to client submittion.

but now the ticket is created when client send an email to my mail server and my database will grab the mail and create a ticket. if the database is able to insert the values into my table, i will be able to print out the result on my page.
Link to comment
Share on other sites

There are a two of ways to read and parse email messages using PHP.

You can used the [url=http://www.php.net/imap]IMAP[/url] functions to read either IMAP or POP3 mailboxes or you can have email addressed to a particular address sent directly to a PHP script which processes it.

Here is a web page that explains the second method:
http://www.evolt.org/article/Incoming_Mail_and_PHP/18/27914/index.html

Ken
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.