Hi,

I'm trying to send HTML in an email by using the mail( ) function. This is a
well documented and much talked about function, and I've already been
successful in sending regular text email and basic HTML. The twist is that I
want to first grab HTML from another server via HTTP, put this content into
a string, and then use mail( ) to send it to an address. I've been working a
whole day, and while the email does send, the message body is blank--no
HTML, no text, nothing.

Here's what I'm trying:

// this doesn't work. blank email body is received
$fp = fopen ("http://www.somesite.com";, "r");
$msg = "";
while($data= fread ($fp, 1024))
    $msg .= $data;
mail($to, $subject, $msg, "MIME-Version: 1.0\r\nContent-Type: text/html;
charset=iso-8859-1\r\n"))

So, a file connection is made to some webpage on another server, and the
data is read into a variable, $msg. Note that the data IS successfully read,
as I've verified by echoing to the browser as well as writing to a local
file. When the data is used as the message of the email to be sent out, a
blank email body is received! However, if HTML is hardcoded into $msg
(instead of read in via an http connection), the email is sent perfectly,
and HTML is seen in the email body:

// this works fine
$msg = "<html><body>testing</body></html"; // this can be as complex as you
like
mail($to, $subject, $msg, "MIME-Version: 1.0\r\nContent-Type: text/html;
charset=iso-8859-1\r\n"))

Can someone please help?







-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to