473,403 Members | 2,222 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

PhpMailer does not show altbody, but unformatted html text

I use phpmailer. I have included the program below. I send an email with a html table. I also include a text to show as alternative for programa that cannot read the html.

When I sent the email, the Outlook shows the content of the table but unformatted. Why does it not sent the text in altbody? I have tried Opera but there it always shows the table although I select plain text mode.

What I want is to send people an html email and if they cannot read it a link to a copy of the email on the internet.

Here the code:
Expand|Select|Wrap|Line Numbers
  1. function MailNew($from,$to,$subject,$text,$htmltext)
  2.   {
  3.   require("phpmailer/class.phpmailer.php");
  4.  
  5.   $mail = new PHPMailer();
  6.   $mail->CharSet = 'UTF-8';
  7.   $mail->IsSMTP();
  8.  
  9.   $mail->From = $from;
  10.   $mail->FromName = $fromname;
  11.   $mail->AddAddress("email@address.it","");
  12.   $mail->AddReplyTo($from,$fromname);
  13.  
  14.   $mail->WordWrap = 50;
  15.   $mail->IsHTML(true);
  16.  
  17.   $mail->Subject = $subject;
  18.   $mail->Body    = $htmltext;
  19.   $mail->AltBody = $text;
  20.  
  21.   if(!$mail->Send())
  22.     {
  23.     echo "Message could not be sent. <p>";
  24.     echo "Mailer Error: " . $mail->ErrorInfo;
  25.     exit;
  26.     }
  27.   }
  28.  
  29. $table .= "<table border=1>";
  30. $table .= "<tr>";
  31. $table .= "<td>";
  32. $table .= "Column 1";
  33. $table .= "</td>";
  34. $table .= "<td>";
  35. $table .= "Column 2";
  36. $table .= "</td>";
  37. $table .= "</tr>";
  38. $table .= "<tr>";
  39. $table .= "<td>";
  40. $table .= "Column 1";
  41. $table .= "</td>";
  42. $table .= "<td>";
  43. $table .= "Column 2";
  44. $table .= "</td>";
  45. $table .= "</tr>";
  46. $table .= "</table>";
  47.  
  48. MailNew("email@address.it","email@address.it","This is subject","This is plain tekst","This is the HTML message body <b>in bold!</b>$table");
  49.  
Mar 25 '13 #1
0 1240

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

Similar topics

1
by: WOJSAL | last post by:
I want show HTML-text (messages, textarea etc.) with TkInter. What free package, module i need? Please help. -- Regards
2
by: bbxrider | last post by:
one of my fist asp pages i have vbscript rountines that are sending page text with response.write they are in the asp file before regular html text yet the html text appears first on the page???...
4
by: Ed West | last post by:
Hello Can I put generic HTML Text in a Placeholder, or does it need to be a server control? If I can't, how can I put dynamically put in some text in a template? ie, in the .ascx file ...
1
by: Filip De Backer | last post by:
Hi everyone, I have some fields from a database which contain html text. How can I show this text in an asp page (<b> must be bold, red must be red text, ...)? thanks for the answers, Filip
2
by: Frank Bishop | last post by:
I have a code snip from 4Guys that uses an html text box name property and I need to use a Web Form control instead. Since the Web Form control does not have the "name" property, how would I do...
2
by: Chad | last post by:
In our application, I would like to send out HTML mail. TO do so, I must do something like this: Mail.Body = <raw HTMLTEXT String> Hence, I would like to know how to get the HTML text for Web...
4
by: sreejith.ram | last post by:
What is the difference/advantages/disadvantages of using Textbox Web Control over HTML Text Box with Run at Server? I could'nt figure out a convincing answer. I was testing it this morning.. I...
7
by: Yeah | last post by:
Ever since I upgraded my Windows display to 120 DPI (kind of a necessary change), fonts have been clearer and graphics have been crisper. However, the 25% automatic increase in the text size on my...
8
chunk1978
by: chunk1978 | last post by:
hi there... i've been building an internet form recently, and i've realized there seems to be a slight difference between the way HTML text is processed between my Mac (Mac OS X v10.4.8) and my PC...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...
0
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...

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.