Jump to content

Something is wrong about the object


cuitw

Recommended Posts

Hi there!

 

I have been sending html email from a filemaker database by passing the recipient, subject, message body and stuff to a php with global variables. (GET)

 

One of my colleagues complained that she could not deliver the email, I looked into it and it turned out to be the reason of "URL too long"... so I tried to change the mechanism by passing only the record ID to the php and have the php file access the database by filemaker API to grab info.

 

Here are the codes:

 

<?php

define('FM_HOST', 'my company domain');

define('FM_FILE', 'filename');

define('FM_USER', 'user');

define('FM_PASS', 'password');

error_reporting(E_ALL);

ini_set('display_errors', '1');

include ('FileMaker.php');

require_once('FileMaker.php');

$fm = new FileMaker(FM_FILE, FM_HOST, FM_USER, FM_PASS);

$record = $fm->getRecordById('filename', $_GET['recordid']);

$to = $record->getfield('to');

$subject = $record->getfield('subject');

$kp = $record->getField('kp_price');

$message = $record->getfield('email_codes_c');

$from = $record->getfield('from');

$replyto = $record->getfield('replyto');

$cc = $record->getfield('cc');

$message = stripcslashes($message);

$message = "<html><body>".wordwrap($message, 70)."</body></html>";

/*

$wrong = array("< td>","<t d>", "<td >" , "< /td>" , "</ td>", "<t d>", "</td >","< tr>","<t r>", "<tr >" , "< /tr>" , "</ tr>", "</t r>", "</tr >" );

$correction = array("<td>","<td>", "<td>" , "</td>" , "</td>", "<td>", "</td>","<tr>","<tr>", "<tr>" , "</tr>" , "</tr>", "</tr>", "</tr>");

$message = str_replace($wrong, $correction, $message);

*/

$headers = "From: " . $from . "\r\n";

$headers .= "Reply-To: " . $replyto . "\r\n";

$headers .= "CC: " . $cc . "\r\n";

$headers .= "MIME-Version: 1.0\r\n";

$headers .= "Content-Type: text/html;charset=ISO-8859-1\r\n";

mail($to, $subject, $message, $headers, $cc);

/*

echo "email sent without error";

*/

echo $message;

echo strlen($message);

?>

 

For some reasons the html codes are being shown in the recipient's mail box "as is", the message header is showing content-type: text/html, if I disable the lines that get data for $message from database and manually type in some html codes to $message, recipients can read it as a html page without problem... Seems to me that something is wrong about the content the variable $message got from the database API... Any suggestions?

 

Here is the message header in case anyone would like to see this too:

 

From:  email address

Subject: Quotation

Date: 19 March 2010 5:51:45 PM GMT+08:00

To:  email address

Reply-To:  email address

Return-Path: <email address>

Received: from murder ([unix socket]) by domain name (Cyrus v2.2.12-OS X 10.4.0) with LMTPA; Fri, 19 Mar 2010 17:51:46 +0800

Received: from localhost (localhost [127.0.0.1]) by domain name (Postfix) with ESMTP id 9A6C7E0A1B8 for <email address>; Fri, 19 Mar 2010 17:51:46 +0800 (HKT)

Received: from domain name ([127.0.0.1]) by localhost (Temp-Server.local [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 07118-09 for <email address>; Fri, 19 Mar 2010 17:51:45 +0800 (HKT)

Received: by domain name (Postfix, from userid 70) id 92BCFE0A1AB; Fri, 19 Mar 2010 17:51:45 +0800 (HKT)

X-Sieve: CMU Sieve 2.2

Mime-Version: 1.0

Content-Type: text/html;charset=ISO-8859-1

Message-Id: <20100319095145.92BCFE0A1AB@domain name>

 

One more info, if I check the length of the codes in filemaker it's about 7k but strlen is suggesting like 11k... but if I echo $message they are like exactly the same, same result if I stripslash it.

 

Your help will be greatly appreciated!

Link to comment
Share on other sites

Thank you for your reply ignace.

 

I agree with you that the email format is probably invalid considering the discrepancy on the length. I am guessing there might be something hidden in the variable $message. I have tried phpmailer too but it was the same. If I pass the email content by global variable, recipients receive it as html without problem, if I get the body message from FileMaker object then reciopients will receive the html source code instead.

 

If this is the case, Zend can fix it only by removing the hidden codes(or whatever it is) from $message. Anyway, I will give Zend a shot right away. Whether or not I can have it fixed this way, I'll post an update.

 

Thank you again for your help!

 

Link to comment
Share on other sites

This is sort of a file for internal use and I have a temporary solution for them to use so I guess it is okay. I didn't have enough time to get it done and I am in the middle of something else right now. I will be posting an update again soon.

 

Thanks again Ignace  ;) You're great!

Link to comment
Share on other sites

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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