cuitw Posted March 22, 2010 Share Posted March 22, 2010 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! Quote Link to comment https://forums.phpfreaks.com/topic/196069-something-is-wrong-about-the-object/ Share on other sites More sharing options...
ignace Posted March 22, 2010 Share Posted March 22, 2010 If they can see your headers as-is that means your e-mail format is invalid which is why they can see your HTML as-is to. If you wrote FileMaker yourself I highly encourage to use a tested version like Zend_Mail which applies e-mail format according to the appropriate RFC Quote Link to comment https://forums.phpfreaks.com/topic/196069-something-is-wrong-about-the-object/#findComment-1029887 Share on other sites More sharing options...
cuitw Posted March 23, 2010 Author Share Posted March 23, 2010 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! Quote Link to comment https://forums.phpfreaks.com/topic/196069-something-is-wrong-about-the-object/#findComment-1030291 Share on other sites More sharing options...
ignace Posted March 23, 2010 Share Posted March 23, 2010 Experimenting is good but not if you have a client waiting then you should be using a sure thing like Zend_Mail Quote Link to comment https://forums.phpfreaks.com/topic/196069-something-is-wrong-about-the-object/#findComment-1030405 Share on other sites More sharing options...
cuitw Posted March 24, 2010 Author Share Posted March 24, 2010 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! Quote Link to comment https://forums.phpfreaks.com/topic/196069-something-is-wrong-about-the-object/#findComment-1030880 Share on other sites More sharing options...
cuitw Posted March 29, 2010 Author Share Posted March 29, 2010 Just a quick update. Haven't got too much time to work on it, the PHP version on my server is still version 4... so I can't install Zend just yet. Will upgrade PHP and try again later. Quote Link to comment https://forums.phpfreaks.com/topic/196069-something-is-wrong-about-the-object/#findComment-1033378 Share on other sites More sharing options...
cuitw Posted April 7, 2010 Author Share Posted April 7, 2010 Final update. I have got the problem solved. Thank you very much for your help, ignace! Quote Link to comment https://forums.phpfreaks.com/topic/196069-something-is-wrong-about-the-object/#findComment-1038185 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.