I am trying to create a php program that will check for the presence of any emails with a keyword in the subject line, then it will retrieve the contents of the email and pass it to a variable.
Can anyone provide me with some helpful information on how to accomplish this?
If you can use imap protocol better, you can try the imap functions of PHP
<?php
$imap = imap_open("{mail.yourserver.com:143}INBOX", "username", "password");
$message_count = imap_num_msg($imap);
for ($i = 1; $i <= $message_count; ++$i) {
$header = imap_header($imap, $i);
if (preg_match('#keyword#',$header['subject'])) {
$body = imap_body($imap, $i);
// your action here
}
}
imap_close($imap);
?>