RE: [PHP] Cannot send a hyperlink

This is a discussion on RE: [PHP] Cannot send a hyperlink within the PHP General forums, part of the PHP Programming Forums category; On Thu, 15 Nov 2007 09:58:59 -0500, "Brad" <brads@ftnco.com> wrote: > Still ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 11-15-2007
T . Lensselink
 
Posts: n/a
Default RE: [PHP] Cannot send a hyperlink

On Thu, 15 Nov 2007 09:58:59 -0500, "Brad" <brads@ftnco.com> wrote:
> Still parsing as text and not html!
>
> <a href="http://www.zoneofsuccessclub.com">link </a>
> //<a href="http://www.zoneofsuccessclub.com">link </a>
>
> $email = $_REQUEST['email'] ;
> $fromaddress .= 'admin@zoneofsuccessclub.com';
> $fromname .= 'Zone of success Club';
> $eol="\r\n";
> $headers = "From: ".$fromname."<".$fromaddress.">".$eol;
> $headers .= "Reply-To: ".$fromname."<".$fromaddress.">".$eol;
> $headers .= "Return-Path: ".$fromname."<".$fromaddress.">".$eol;
> $headers .= "Message-ID: <".time()."-".$fromaddress.">".$eol;
> $headers .= "X-Mailer: PHP ".phpversion().$eol;
> $body .= "--".$htmlalt_mime_boundary.$eol;
> $body .= "Content-Type: text/html; charset=iso-8859-1".$eol;
> $body .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
> $body = "<a href=\"http://www.zoneofsuccessclub.com\">link </a>\n";
> mail($email, $subject, $body, $headers);
>
> -----Original Message-----
> From: Per Jessen [mailto:per@computer.org]
> Sent: Thursday, November 15, 2007 9:48 AM
> To: php-general@lists.php.net
> Subject: RE: [php] Cannot send a hyperlink
>
> Brad wrote:
>
>> Beginning with
>> $headers .= "--".$htmlalt_mime_boundary.$eol;
>> It starts to read it as text and not html??
>>
>> Could this be a server side problem?

>
> Nope.
>
>> $email = $_REQUEST['email'] ;
>> $fromaddress .= 'admin@zoneofsuccessclub.com';
>> $fromname .= 'Zone of success Club';
>> $eol="\r\n";
>> $headers = "From: ".$fromname."<".$fromaddress.">".$eol;
>> $headers .= "Reply-To: ".$fromname."<".$fromaddress.">".$eol;
>> $headers .= "Return-Path: ".$fromname."<".$fromaddress.">".$eol;
>> $headers .= "Message-ID: <".time()."-".$fromaddress.">".$eol;
>> $headers .= "X-Mailer: PHP ".phpversion().$eol;
>> $headers .= "--".$htmlalt_mime_boundary.$eol;
>> $headers .= "Content-Type: text/html; charset=iso-8859-1".$eol;
>> $headers .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
>> $body = "<a href=\"http://www.zoneofsuccessclub.com\">link </a>\n";

>
> You have a MIME boundary where it doesn't belong. MIME boundaries are
> for the body, not the header.
>
>
> /Per Jessen, Zürich


Exactly. The boundry should be part of the body. And i agree with stut.
Just use
PHPMailer for this stuff. That's what it's for.

When sending mail from PHP i always make sure there is a fallback for
clients
that don't accept HTML mail. When using your snippet my mail ends up in the
junkmail
box. And it's not HTML either. The headers are messed up. So a small
example:

$boundary = md5(uniqid(rand(), true));

$headers = "From: name <some@email.tld>\r\n";
$headers .= "To: name <some@email.tld>\r\n";
$headers .= "Subject: some subject\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: multipart/alternative; boundary=" . $boundary .
"\r\n";

$body = "\r\n\r\n--" . $boundary . "\r\n";
$body .= "Content-Type: text/plain; charset=iso-8859-1\r\n\r\n";

$body .= "... plain text test version ....";

$body .= "\r\n\r\n--" . $boundary . "\r\n";
$body .= "Content-Type: text/richtext; charset=iso-8859-1\r\n";

$body .= ".... richtext test version ...";

$body .= "\r\n\r\n--" . $boundary . "\r\n";
$body .= "Content-Type: text/html; charset=iso-8859-1\r\n";

$body .= ".... HTML version ...";

$body .= "\r\n\r\n--" . $boundary . "--\r\n";

mail("some@email.tld", "(some subject)", $body, $headers);
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 04:31 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0