Discussion:
Complete IMAP Message Body
Ron Piggott
2014-05-16 21:44:38 UTC
Permalink
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
Ron Piggott
2014-05-16 23:30:22 UTC
Permalink
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
i***@btinternet.com
2014-05-19 10:31:41 UTC
Permalink
Can someone suggest a good starting point for integrating ical calendars
into a web site with php? The sources I found are either short of
detail or much too detailed.

John
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Ashley Sheridan
2014-05-19 10:49:51 UTC
Permalink
Post by i***@btinternet.com
Can someone suggest a good starting point for integrating ical
calendars
into a web site with php? The sources I found are either short of
detail or much too detailed.
John
First, please don't hijack a thread, create a new email, as many email clients group by thread not subject line.

The iCal format is actually just plain text, you can find some simple examples on Wikipedia. A few things to bear in mind, get the dates right including any timezone offsets and dst offsets. Also, it helps if you set the headers right in php so that the browser correctly sees it as an iCal doc and not a text file, and you might want to set the content-disposition header to force it to download on some unruly browsers.

Thanks,
Ash
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Loading...