warwick Posted February 11, 2010 Share Posted February 11, 2010 I am creating php code to take information from web form and email to Goldmine (my companies CRM system). For data to be automatically imported into Goldmine database it needs to have a specific header content type (and correct body formating and password). It also seeems that emails must be in plain text, HTML content does not seem to work. Required is Content-Type: text/x-gm-impdata In my code I have two sections, the original using mail() which works on my development PC. But the final code will be on different system which requires SMTP authentication. I have therefore written a second code section with PHPmail. Currently while trying to get this working I am sending two emails with each submitted form. The code section using mail, works fine, and imports straight into Goldmine. The code section using PHPmail sends email, but this does not import into Goldmine. The email is recieved, but I beleive the header information is not correct for Goldmine. When the email is being recieved into Goldmine (from using PHPmail) additional header information is being added (than I expected) - a second Content-Type is appearing, which I think is confusing Goldmine. Can someone please assist with sorting out the header code. Note that in the second section, while I am using PHPmail for it authentication abilitiy, at this stage I am not actually using SMTP authentication as my development system does not require it. I am using Windows XP with Apache 2.2.14 and PHP 5.3.1 Code snipits (I have xxx xyz'd out the actual email addresses): $Body = ""; $Body = $Body ."[instructions]\n"; $Body = $Body ."DupCheck1=EMAIL\n"; $Body = $Body ."DupLogic=OR\n"; $Body = $Body ."OnNewSendGMEmail=WARWICK\n"; $Body = $Body ."OnDUPSendGMEmail=WARWICK\n"; $Body = $Body ."OnNewAttachTrack=NewsletterPreferenceChange,WARWICK\n"; $Body = $Body ."OnDUPAttachTrack=NewsletterPreferenceChange,WARWICK\n"; $Body = $Body ."Password=goldmine\n"; $Body = $Body ."[Data]\n"; $Body = $Body ."CONTACT=Test\n"; $Body = $Body ."[email protected]\n"; $Body = $Body ."UPROT=Finaly\n"; #################### Standard non SMTP mailer $ToSubject="sub_change using standard non SMTP mail"; $SendToEmail="[email protected]"; $Header="From: [email protected]"; $Header= $Header ."\r\nContent-Type: text/x-gm-impdata\r\n"; if(mail($SendToEmail, $ToSubject, $Body, $Header)) { print "Your data has been recorded successfully!<br>" .$SendToEmail ."<br>" .$ToSubject ."<br>" .$Header ."<br>"; } else { print("There was a mailer failure.\n\n \n".$Body."\n\n"); } #################### PHP mailer (with SMTP authenitication) include_once('./phpmailer/class.phpmailer.php'); $mail = new PHPMailer; $mail->IsSMTP(); // telling the class to use SMTP $mail->Host = "smtp.xyz.com"; // SMTP server $mail->SMTPDebug = 2; // enables SMTP debug information (for testing) // 1 = errors and messages // 2 = messages only $mail->SMTPAuth = false; // true = enable SMTP authentication $mail->Username = "xyz"; // SMTP account username $mail->IsHTML(FALSE); $mail->Body=$Body; $mail->addCustomHeader("Content-Type: text/x-gm-impdata; charset=" .chr(34) ."iso-8859-1".chr(34) ."\r\n Content-Transfer-Encoding; 8-bit\r\n"); $mail ->ClearAddresses(); $mail ->AddAddress('[email protected]', $name='{$GM-WebImport$}'); $mail ->From = 'xyz2.xyz'; $mail -> FromName = '[email protected]'; $mail ->Subject = 'from sub change using PHPmailer with SMTP'; if ($mail -> Send()) { print '<p> Your request has been submitted!.</p>'; //exit(); } else { echo $mail->ErrorInfo; echo "mail error "; } ###### end of relevent code Here is the relevent section of the two emails Email from PHPmail (that does not work in GM- Note the second Content_Type: statement) To: {$GM-WebImport$} <xxxx> From: "xxx" <xxxx> Subject: from sub change using PHPmailer with SMTP Message-ID: <[email protected]> X-Priority: 3 X-Mailer: PHPMailer 5.1 (phpmailer.sourceforge.net) Content-Type: text/x-gm-impdata; charset="iso-8859-1" Content-Transfer-Encoding; 8-bit MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="iso-8859-1" X-Spam-Score: -0.7 X-Spam-Report: 0.1 FORGED_RCVD_HELO Received: contains a forged HELO 1.8 HEADER_COUNT_CTYPE Multiple Content-Type headers found -2.6 BAYES_00 BODY: Bayesian spam probability is 0 to 1% [score: 0.0000] 0.0 UPPERCASE_25_50 message body is 25-50% uppercase [instructions] DupCheck1=EMAIL DupLogic=OR OnNewSendGMEmail=WARWICK OnDUPSendGMEmail=WARWICK OnNewAttachTrack=NewsletterPreferenceChange,WARWICK OnDUPAttachTrack=NewsletterPreferenceChange,WARWICK Password=goldmine [Data] CONTACT=Test [email protected] UPROT=Finaly Here is the email from mail(), which works in Goldmine Return-Path: <xxx> Received: xxxx Date: Fri, 12 Feb 2010 09:20:59 +1300 Subject: sub_change using standard non SMTP mail To: xxx X-PHP-Originating-Script: 0:sub_change.php From: [email protected] Content-Type: text/x-gm-impdata X-Spam-Score: -1.6 X-Spam-Report: 1.0 NO_REAL_NAME From: does not include a real name -2.6 BAYES_00 BODY: Bayesian spam probability is 0 to 1% [score: 0.0000] 0.0 MIME_HEADER_CTYPE_ONLY 'Content-Type' found without required MIME headers 0.0 UPPERCASE_25_50 message body is 25-50% uppercase Message-Id: <20100211202102.YFWS4221.xxxx> [instructions] DupCheck1=EMAIL DupLogic=OR OnNewSendGMEmail=WARWICK OnDUPSendGMEmail=WARWICK OnNewAttachTrack=NewsletterPreferenceChange,WARWICK OnDUPAttachTrack=NewsletterPreferenceChange,WARWICK Password=goldmine [Data] CONTACT=Test [email protected] UPROT=Finaly Link to comment https://forums.phpfreaks.com/topic/191820-phpmail-headers-content-type/ Share on other sites More sharing options...
schilly Posted February 11, 2010 Share Posted February 11, 2010 i think you need to either hack PHPMailer to remove the content-type header it adds or write your own smtp authentication. Link to comment https://forums.phpfreaks.com/topic/191820-phpmail-headers-content-type/#findComment-1011017 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.