Bastien the value of â $body â is empty (not NULL). Am I doing something wrong?
- Other values of â function getInbox() â are giving results --- such as âheaderâ shown here:
===
date Fri, 16 May 2014 19:04:36 -0400
Date Fri, 16 May 2014 19:04:36 -0400
subject Re: Test message
Subject Re: Test message
message_id <***@RonPiggottPC>
toaddress ***@theverseoftheday.info
to:
mailbox devotion.inquiries
host theverseoftheday.info
fromaddress Ron Piggott <***@actsministries.org>
from:
personal Ron Piggott
mailbox ron.piggott
host actsministries.org
reply_toaddress Ron Piggott <***@actsministries.org>
reply_to:
personal Ron Piggott
mailbox ron.piggott
host actsministries.org
senderaddress Ron Piggott <***@actsministries.org>
sender:
personal Ron Piggott
mailbox ron.piggott
host actsministries.org
Recent R
Unseen
Flagged
Answered
Deleted
Draft
Msgno 1
MailDate 16-May-2014 19:04:36 -0400
Size 1213
===
<?php
public function getInbox()
{
$message_count = imap_num_msg($this->getConnection());
$array = array();
$array['message_count'] = $message_count;
for ($i = 0; $i < $message_count; $i++) {
$array[] = array(
'index' => ( $i + 1 ),
'header' => imap_headerinfo($this->getConnection(), ( $i + 1 ) ),
'body' => imap_body($this->getConnection(), ( $i + 1 ) ),
'structure' => imap_fetchstructure($this->getConnection(), ( $i + 1 ) )
);
}
return $array;
}
?>
Then I use a WHILE loop to process the message(s):
<?php
$inbox = $this->getInbox();
$messaage_counter = 0;
while ( $messaage_counter < $inbox['message_count'] ) {
# variable defaults
...
$body = $inbox[$messaage_counter]['body'];
...
$this->saveNewEmail( $date_message_received , $from_name , $from_mail_address , $membership_reference , $our_email_address_reference , $headers , $subject , $body , $text_message , $html_message );
}
# Then I use this function to save the message details to the database
public function saveNewEmail( $date_message_received , $from_name , $from_mail_address , $membership_reference , $our_email_address_reference , $headers , $subject , $body , $text_message , $html_message )
{
$dsh = "mysql:host=localhost;dbname=" . $MariaDB['db']['database'];
$dbh = new PDO($dsh, $MariaDB['db']['username'], $MariaDB['db']['password']);
$query = "INSERT INTO `email_message_inbox`(`reference`, `date_message_received`, `from_name`, `from_email_address`, `membership_reference`, `our_email_address_reference`, `headers`, `subject`, `body`, `text_message`, `html_message`, `date_message_converted_to_customer_service_contact_center`) VALUES ( NULL , :date_message_received , :from_name , :from_mail_address , :membership_reference , :our_email_address_reference , :headers , :subject , :body , :text_message , :html_message , '0000-00-00 00:00:00.000000' )";
$email_login_credentials = array();
if ($stmt = $dbh->prepare($query)) {
$stmt->bindValue(':date_message_received', $date_message_received , PDO::PARAM_STR);
$stmt->bindValue(':from_name', $from_name , PDO::PARAM_STR);
$stmt->bindValue(':from_mail_address', $from_mail_address , PDO::PARAM_STR);
$stmt->bindValue(':membership_reference', $membership_reference , PDO::PARAM_INT);
$stmt->bindValue(':our_email_address_reference', $our_email_address_reference , PDO::PARAM_INT);
$stmt->bindValue(':headers', $headers , PDO::PARAM_STR);
$stmt->bindValue(':subject', $subject , PDO::PARAM_STR);
$stmt->bindValue(':body', $body , PDO::PARAM_STR);
$stmt->bindValue(':text_message', $text_message , PDO::PARAM_STR);
$stmt->bindValue(':html_message', $html_message , PDO::PARAM_STR);
if ($stmt->execute() or die(print_r($stmt->errorInfo(), true))) {
$email_message_inbox_reference = $dbh->lastInsertId();
}
}
unset($dbh);
return $email_message_inbox_reference;
}
?>
Ron Piggott
www.TheVerseOfTheDay.info
From: Bastien Koert
Sent: Friday, May 16, 2014 6:10 PM
To: Ron Piggott ; php-***@lists.php.net
Subject: Re: [PHP] Complete IMAP Message Body
Will http://ca1.php.net/manual/en/function.imap-body.php imap_body do the trick?
Bastien
Sent from Acompli
On Fri, May 16, 2014 at 2:45 PM -0700, "Ron Piggott" <***@actsministries.org> wrote:
Is there a command that would give me the equivalent of â imap_headerinfo â for the complete message body (sections & sub sections) Ron
Ron Piggott
www.TheVerseOfTheDay.info