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 [email protected]. The database will get the email from the mail server([email protected]), 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
https://forums.phpfreaks.com/topic/27460-get-mail-from-mail-server-and-process-it/
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]
oh.. for example, if i'm the user, i send a email to this address [email protected], using hotmail, google, or yahoo.

this is the content of my mail:

To: [email protected]
From: hanwei
Header: trouble ticket
Message : i have a trouble ticket


so when [email protected] 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 [email protected] 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..
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.
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 [email protected], 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.
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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.