Jump to content

PHPmail headers Content-Type


warwick

Recommended Posts

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=Testnew@test.com\n";

  $Body = $Body ."UPROT=Finaly\n";

 

  #################### Standard non SMTP mailer

  $ToSubject="sub_change using standard non SMTP mail";

  $SendToEmail="xyz@zyz.com";

  $Header="From: xyz1@zyx.com";

  $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('xyz@xyz.com', $name='{$GM-WebImport$}');

 

  $mail ->From = 'xyz2.xyz';

  $mail -> FromName = 'xyz2@xyz.com';

  $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: <89f0dc479d11004ae6d4e17cf79d8c6c@testsite.co.nz.local>

  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=Testnew@test.com

  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: xyz@zyx.com

  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=Testnew@test.com

  UPROT=Finaly

Link to comment
Share on other sites

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.