473,408 Members | 1,722 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,408 software developers and data experts.

Send HTML mail with PEAR

Hi!

Im trying to send a html mail through PEAR but what I get in mail is blank email.

Below is my code

[PHP]
require_once "Mail.php";
require_once "Mail\mime.php";

$html = @file_get_contents(GetEmailBody());

$message = new Mail_mime();
$message->setHTMLBody($html);
$body = $message->get();
$from = "abc@sample.com";
$namefrom = "Sample";
$to ="johnsmith@sample.com";
$nameto = "John Smith";
$subject = "Sample";

$host = "mail.sample.com";
$username = "sample@sample.com";
$password = "sample";

$headers = array ('From' => $from,'To' => $to, 'Subject' => $subject);
$smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password));

$mail = $smtp->send($to, $headers, $body);

if (PEAR::isError($mail))
{
echo("<p>".$mail->getMessage()."</p>");
}
else
{
echo("<p>Message successfully sent!</p>");
}
[/PHP]

Thank you
Daniel Nawaz
Oct 6 '07 #1
7 3292
pbmods
5,821 Expert 4TB
Heya, Daniel.

What does GetEmailBody() return?
Oct 6 '07 #2
returns a string containing HTML tags and data....

when i simply do this
Expand|Select|Wrap|Line Numbers
  1. $body = GetEmailBody();
instead of setting Mime_mail

I'm mailed with HTML source text. Not compiled page.
Oct 6 '07 #3
pbmods
5,821 Expert 4TB
Heya, daniyalnawaz.

Please use CODE tags when posting source code:

[CODE=php]
PHP code goes here.
[/CODE]

Try removing the file_get_contents() around GetEmailBody().
Oct 6 '07 #4
Hi!

Now im again getting HTML text in the mail.
Oct 6 '07 #5
and on thing more...

i change the $html to

[PHP]$html = "<table width='100%' border='1'><tr><td>HELLO</td></tr><table>";[/PHP]

and what i recieve in email is

[HTML]<table width=3D'100%' border=3D'1'><tr><td>HELLO</td></tr><table>[/HTML]

what 3Ds are doing in it?
Oct 6 '07 #6
pbmods
5,821 Expert 4TB
Heya, Daniyalnawaz.

This is expected behavior.

Have a look at this page.
Oct 6 '07 #7
Ok what should I do? Am I missing something? Any other way i should use?

Is my HTML incorrect?

[PHP]$html = "<html><body><table width='100' border='1'><tr><td>HELLO</td></tr></table></body></html>";[/PHP]
Oct 6 '07 #8

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

Similar topics

4
by: philphanluvr | last post by:
How do I sent content of a PHP form via HTML email? For example, fields $name, $city, $state, $phone, $location to HTML: <p>Congratulations $name from $city, $state with the phone # $phone ....
2
by: Alvaro G Vicario | last post by:
I'm trying to send e-mail using PEAR's Mail class--for testing purposes actually, I've never had any problem with conventional mail(). This is what my code looks like: ...
3
by: marsandys | last post by:
Hello, I have this code below, which I am trying to have it send HTML formatted mail with embedded images. I can get this to send the mail, but it spits out a bunch of junk . I know this should...
6
by: monomaniac21 | last post by:
hi all how can u send a plain text version of an email with the html so that the users mail client can access this plain text version? kind regards marc
2
by: Malli mindwave | last post by:
Hi, We are using the yahoowebHostiing service for my company website, In that one screen of the SendComments/FeedBack section is there, I'm basically dot.net develeoper ,but yahoowebhosting not...
21
by: Dev | last post by:
Dear All, I have created a website. in the contact us page i want to send all information (Entered by visitor in text boxex) directly to my e-mail address. to do this i have no idea because i am...
1
by: vps | last post by:
I have Apache 2.2 server running on Windows XP SP2 with PHP 5.2.5. I have run go-pear.bat in PHP directory (system-wide, all defaults). Running “pear” command lists additional commands. I...
7
by: John Drako | last post by:
Currently, I run postfix on my own server to send message from my site (password requests, account activation notices and other messages). I have phpMailer on the server and all the messages...
1
by: ghjk | last post by:
I want to send mail when user click "forgot password " button. This is my code and It doesn't send a mail. Could somebody tell me what is wrong with my code? require_once "Mail.php"; $from =...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
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
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
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...

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.