post email content to database

Discussion in 'PHP' started by mediaguru, Oct 22, 2009.

  1. #1
    I have a client who wants me to make a script which does this:

    1. someone fills out an email with specific fields and emails it to my client.
    2. the email fields are entered into fields in the client's database

    name / project / date etc are type and sent in via email

    name / project / date are then automatically entered into the database when the email is received by the server.

    Is this even possible? I don't know why they can't just use a simple form. This is what they want.
     
    mediaguru, Oct 22, 2009 IP
  2. mastermunj

    mastermunj Well-Known Member

    Messages:
    687
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    110
    #2
    if the application is made by you, why don't you put an entry in database before sending an email?
     
    mastermunj, Oct 22, 2009 IP
  3. mediaguru

    mediaguru Peon

    Messages:
    219
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Not sure I understand your question.

    Basically the client will not "know" jobs are coming in. They want jobs to be submitted by email which is then automatically entered into the db.
     
    mediaguru, Oct 22, 2009 IP
  4. mastermunj

    mastermunj Well-Known Member

    Messages:
    687
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    110
    #4
    Ok, let me ask few questions to make it clear for both of us.

    1. Do you want to have a form where visitor can fill in details, which when submitted sends an email to client?
    2. Is this form already there and you have to integrate email functionality? OR you have to make form from scratch?
     
    mastermunj, Oct 22, 2009 IP
  5. califmerchant

    califmerchant Active Member

    Messages:
    112
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    63
    #5
    it's possible, you have to read the incoming emails with php with imap and then parse the email for the data ...


    $server = "mail.yourdomain.com";
    $user = "incomingemail@yourdomain.com";
    $pass = "emailpass";
    $conn = @imap_open("{localhost:143/notls}", $user, $pass) or die(imap_last_error());$headers = @imap_headers($conn) or die("No emails found.");
    $numEmails = sizeof($headers);
    echo "You have $numEmails emails in your mailbox.<P>";
    for($i = 1; $i < $numEmails+1; $i++){
    $mailHeader = @imap_headerinfo($conn, $i);
    $message=@imap_body ($conn,$i);
    $headers=@imap_fetchheader ($conn,$i);


    //do your parsing here on the message

    //$check=@imap_delete($conn,$i);
    }


    i use this code for http://www.cbcjobs.com to process job emails :)
     
    califmerchant, Oct 22, 2009 IP
  6. mediaguru

    mediaguru Peon

    Messages:
    219
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Nope that's not it. That would be easy to do and I'm trying to talk them into that. But they want their server to automatically add emails which are sent in from a template, entered into the DB so an "admin" can deal with them online and process "jobs"...

    Definitely a "form" would be the easiest.
     
    mediaguru, Oct 22, 2009 IP
  7. mediaguru

    mediaguru Peon

    Messages:
    219
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Thanks califmerchant

    I'll see if I can figure out how to integrate this. I may have some more questions for you soon... :)
     
    mediaguru, Oct 22, 2009 IP
  8. mediaguru

    mediaguru Peon

    Messages:
    219
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #8
    As it turns out, this client bailed on the idea. I was pretty close to having it all done too. The screwy thing was that some of the UID's didn't convert to variables, some did. I suppose that was because of characters withing the UID?
     
    mediaguru, Oct 31, 2009 IP