473,699 Members | 2,701 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PHP, Pear, SMTP and random equal signs in html emails

16 New Member
Hey everyone,

I am stumped once more and you guys have always helped in one way or the other.

I am just now starting to fool around with using PEAR to send html emails. Following the sample scripts -- http://www.phpmaniac.net/wiki/index....ple_recipients -- I was able to send html emails with no problem.

However, when I applied these concepts to a dynamically generated email, the recipients would receive an email with random equal signs appearing in the email.

Here's the code:
Expand|Select|Wrap|Line Numbers
  1.     $message = '<table>';
  2.         // used for displaying thank you page after the form is submitted
  3.     $email_message = $new_html_var2;
  4.  
  5.     if(!empty($_POST['typeSub']))
  6.     {
  7.         $message =$message. '<tr><td>Thank you for ordering  '.$_POST['typeSub'].' subscription of Script Magazine</td></tr>';
  8.     }
  9.     if(!empty($_POST['bfname']))
  10.     {
  11.         $message=$message. '<tr><td>Billing Info'.'</td></tr><tr><td>'.'First Name: '.$_POST['bfname'].'</td></tr>';
  12.     }
  13.     if(!empty($_POST['blname']))
  14.     {
  15.         $message=$message. '<tr><td>Last Name: '.$_POST['blname'].'</td></tr>';
  16.     }
  17.     if(!empty($_POST['bcompany']))
  18.     {
  19.         $message=$message. '<tr><td>Company: '.$_POST['bcompany'].'</td></tr>';
  20.     }
  21.     if(!empty($_POST['baddress1']))
  22.     {
  23.         $message=$message. '<tr><td>Address 1: '.$_POST['baddress1'].'</td></tr>';
  24.     }
  25.     if(!empty($_POST['baddress2']))
  26.     {
  27.         $message=$message. '<tr><td>Address 2: '.$_POST['baddress2'].'</td></tr>';
  28.     }
  29.     if(!empty($_POST['bcity']))
  30.     {
  31.         $message=$message. '<tr><td>City: '.$_POST['bcity'].'</td></tr>';
  32.     }
  33.     if(!empty($_POST['bstate']))
  34.     {
  35.         $message=$message. '<tr><td>State: '.$_POST['bstate'].'</td></tr>';
  36.     }
  37.     if(!empty($_POST['bzip']))
  38.     {
  39.         $message=$message. '<tr><td>Zip/Postal Code: '.$_POST['bzip'].'</td></tr>';
  40.     }
  41.     if(!empty($_POST['bcountry']))
  42.     {
  43.         $message=$message. '<tr><td>Country: '.$_POST['bcountry'].'</td></tr>';
  44.     }
  45.     if(!empty($_POST['bemail']))
  46.     {
  47.         $message=$message. '<tr><td>Email: '.$_POST['bemail'].'</td></tr>';
  48.     }
  49.     if(!empty($_POST['bphone']))
  50.     {
  51.         $message=$message. '<tr><td>Phone: '.$_POST['bphone'].'</td></tr>';
  52.     }
  53.     if(!empty($_POST['ACCT']))
  54.     {
  55.         $message=$message. '<tr><td>Card number ending in: '.substr($_POST['ACCT'], -4).'</td></tr>';
  56.     }
  57.  
  58.     if(!empty($_POST['sfname']))
  59.     {
  60.         $message=$message. '<tr><td>Shipping Info'.'</td></tr><tr><td>'.'First Name: '.$_POST['scompany'].'</td></tr>';
  61.     }
  62.     if(!empty($_POST['slname']))
  63.     {
  64.         $message=$message. '<tr><td>Last Name: '.$_POST['slname'].'</td></tr>';
  65.     }
  66.     if(!empty($_POST['scompany']))
  67.     {
  68.         $message=$message. '<tr><td>Company: '.$_POST['scompany'].'</td></tr>';
  69.     }
  70.     if(!empty($_POST['saddress1']))
  71.     {
  72.         $message=$message. '<tr><td>Address 1: '.$_POST['saddress1'].'</td></tr>';
  73.     }
  74.     if(!empty($_POST['saddress2']))
  75.     {
  76.         $message=$message. '<tr><td>Address 2: '.$_POST['saddress2'].'</td></tr>';
  77.     }
  78.     if(!empty($_POST['scity']))
  79.     {
  80.         $message=$message. '<tr><td>City: '.$_POST['scity'].'</td></tr>';
  81.     }
  82.     if(!empty($_POST['sstate']))
  83.     {
  84.         $message=$message. '<tr><td>State: '.$_POST['sstate'].'</td></tr>';
  85.     }
  86.     if(!empty($_POST['szip']))
  87.     {
  88.         $message=$message. '<tr><td>Zip/Postal Code: '.$_POST['szip'].'</td></tr>';
  89.     }
  90.     if(!empty($_POST['scountry']))
  91.     {
  92.         $message=$message. '<tr><td>Country: '.$_POST['scountry'].'</td></tr>';
  93.     }
  94.     $message=$message. '</table>';
  95.  
  96.     $email_message .= $message.'</div></body></html>';
  97.  
  98.     $message2 = '<html><body>'.$message;
  99.     $message2 .= '</body></html>';
  100.  
  101.     $my_subject = 'Some Magazine Order';
  102.  
  103.     $recipients = "'<someone1@example.com>, <someone2@example.com>, ";
  104.     $recipient = $_POST['bemail'];
  105.  
  106.  
  107.     $from_mail = "noreply@example.com";
  108.     // To send HTML mail, the Content-type header must be set
  109. include('Mail.php');
  110. include('Mail/mime.php');
  111.  
  112.  
  113. $all_recipients = $recipients."<".$recipient.">'";
  114.  
  115. $html = $message2;
  116. //$crlf = "rn";
  117. $hdrs = array('From'    => $from_mail,
  118.               'To'      => $all_recipients,
  119.               'Subject' => $my_subject,
  120.               'Headers' => $hdrs
  121.               );
  122.  
  123.     $mime = new Mail_mime();
  124.        // $mime->setTXTBody($text);
  125.         $mime->setHTMLBody($html);
  126.        // $mime->addAttachment($file,'application/octet-stream');
  127.  
  128. $body = $mime->get();
  129. $hdrs = $mime->headers($hdrs);
  130. $mail =& Mail::factory('mail', $params);
  131. $mail->send($all_recipients, $hdrs, $body); 
  132.  
  133. if (PEAR::isError($mail)) {
  134.   echo("<p>" . $mail->getMessage() . "</p>");
  135.  } else {
  136.   echo($email_message);
  137.  }
  138.  
Here's the result:
Expand|Select|Wrap|Line Numbers
  1. <tbody><tr><td>Thank you for ordering  1 year US subscription o=
  2. f some Magazine</td></tr><tr><td>Billing Info</td></tr><tr><td>First Name=
  3. : kronus</td></tr><tr><td>Last Name: agia</td></tr><tr><td>Company: fd</td>=
  4. </tr><tr><td>Address 1: olympus</td></tr><tr><td>City: metro</td></tr><tr>&lt;=
  5. td&gt;State: California</tr><tr><td>Zip/Postal Code: 90004</td></tr><tr>&lt;=
  6. td&gt;Country: United States</tr><tr><td>Email: someemail@hotmail.com</td></tr><tr><td>Phone: 8185555555</td></tr><tr><td>Card number ending in: 510=
  7. 0</td></tr><tr><td>Country: United States</td></tr></tbody>
  8.  
Mar 26 '09 #1
0 3210

Sign in to post your reply or Sign up for a free account.

Similar topics

4
3925
by: ,hj | last post by:
From: ",hj" <webmaster@mail.com> Subject: Losing random characters in HTML email Date: 28 November 2003 17:21 I've narrowed down my code as much as I can so that I can show you this bug. The reason the a's are there and not removed is because if I remove them the problem doesn't show itself. It seems that there is a pattern and the nth character does not show. Weird stuff.
1
2890
by: dan glenn | last post by:
I'm creating HTML emails from a PHP site and sending them out to an email list (just about 40 people so far are on this list). I've tested and confirmed that these emails work in yahoo.com's webmail. And I know they work on *my* Outlook Express. But I have one person (I know of) who gets the emails as plain text, so she sees the HTML code for the email instead of its proper representation. She has, like myself, OE6, and other html emails...
2
3201
by: Damien | last post by:
Hi to all, After hours of attempts and "googling", I'm still pulling my hair off my head when I try to send multipart html emails. It "works" on PCs with Outlook when I juste send a single "related" mail: one part for the HTML body, and several for the images. However, the images do not show on a Mac. I also wanted to have an "alternate", plain text message. I've tried the method described by Zend and PHPBuilder, but no luck...
2
5847
by: lkrubner | last post by:
When I had these two lines in my code: if ($executed == "The command didn't exist") { $this->core->error("In CommandRenderAllActionsInAnArray we sought the command '$commandName' but ExteriorCommands could not find it. It returned the value: '$executed'.", "CommandRenderAllActionsInAnArray");
8
2301
by: John | last post by:
Hi I am using the following code to send html emails via outlook. objOutlook = CreateObject("Outlook.Application") objOutlookMsg = objOutlook.CreateItem(Outlook.OlItemType.olMailItem) fso = CreateObject("Scripting.FileSystemObject") ts = fso.OpenTextFile(m_objParentForm.txtHtml.Text.ToString, 1) eMessage = ts.ReadAll With objOutlookMsg
7
1749
by: Tappy Tibbons | last post by:
We are writing a dotnet app that among other things retrieves messages from a standard POP3 mailbox, and then performs certain actions with that email automatically. Some of the emails are coming in as HTML, which makes the email itself 8 times as large when it comes time to store it, as well as makes it impossible to display to the user using any sort of standard dotnet control. Is there a way to STRIP OUT all the html tags and get...
12
3930
by: Dave G | last post by:
Apologies if this has been covered before - I couldn't find it. I currently use ASPEmail to create and send HTML emails from an Access database. The text is personalised and includes embedded graphics, eg logos and even the recipients photo. Note that everything is embedded, no attachments are sent. ASPEmail works a treat but is very long winded to create. The email designs come to me as finished HTML but I have to extract the source and...
21
2730
by: maya | last post by:
hi, I'm designing an HTML email for a client.. I know general guidelines (no CSS, no JavaScript... although I do use limited CSS, inside tags (as in <span style=".."we do this at work and it works fine, so I figured it's ok..) but I have a few more questions, for example, is it ok to do client-side image-maps? is there a web page somewhere with general guidelines for HTML e-mails? (and what is best way to test HTML e-mails? (I...
3
3107
by: CJM | last post by:
David, Thanks for the reply. Responses inline: "David E. Ross" <nobody@nowhere.notwrote in message news:OZadnaBdOMGpYb3VnZ2dnUVZ_vOdnZ2d@softcom.net... This is a promotional mailshot so image is important. I understand what you
0
8686
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9173
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8882
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7748
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6533
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5872
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4375
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4627
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3057
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.