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; Brad wrote: > No access to the server command line to install it! > And, I am into this guy ...


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
Stut
 
Posts: n/a
Default Re: [PHP] Cannot send a hyperlink

Brad wrote:
> No access to the server command line to install it!
> And, I am into this guy too deep to switch technologies. For the next time
> around, no problem, this time I am just trying to get php to do what it is
> supposed to do.


You don't need command line access to install it. PHPMailer consists of
PHP only - nothing to install but PHP files. See here:
http://phpmailer.sourceforge.net/install.php

> The suggestion of mime was presented to me from another kind sole trying to
> help that knows more than I and recommended on other help files.
>
> Why is php refusing to parse as html?


And here lies the basic problem. PHP is *not* the thing that's refusing
to parse it as HTML. Since you don't know that you really should do a
lot of reading before you try sending HTML emails without using
something like PHPMailer.

For beeps and farts I've "fixed" your code, but even though it will now
"work" it is nowhere near the right way to send this type of email, but
my life is probably going to be too short to tell you what you could
easily find out yourself.

$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 .= 'X-Mailer: PHP '.phpversion().$eol;
$headers .= 'Content-Type: text/html; charset=iso-8859-1'.$eol;
$headers .= 'Content-Transfer-Encoding: 8bit';
$subject = 'This is my spam, worship me';
$body = '<a href="http://www.zoneofsuccessclub.com/">link</a>';
mail($email, $subject, $body, $headers);

Some *important* notes...

* I defined $subject because it tries to use it.
* You don't need to provide the MessageID - your mail server will do
that for you... correctly.
* You don't need to add two carriage returns at the end of the headers -
PHP will do that for you.
* This email will be in HTML only which makes it a lot more likely to
get flagged as spam.
* If you're on a unix-based platform you really should be using the 5th
parameter to mail, but that's probably going to confuse the hell out of
you so I won't mention it. D'oh!
* This code is not secure. It's trivial to inject headers (and a body
too) into the message. You should be validating that $_REQUEST['email']
is a valid email address and just a valid email address.

-Stut

--
http://stut.net/

> -----Original Message-----
> From: Stut [mailto:stuttle@gmail.com]
> Sent: Thursday, November 15, 2007 9:46 AM
> To: Brad
> Cc: 'Daniel Brown'; 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?
>>
>> $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";
>> mail($email, $subject, $body, $headers);

>
> You should not have a mime boundary in your headers. Why not use
> PHPMailer? All this (apparently) complicated stuff is already
> implemented for you. Either that or spend a few days learning about the
> structure of emails by following the links Daniel Brown sent you a few
> emails ago.
>
> PHPMailer can be found here: http://phpmailer.sf.net/
>
> -Stut
>

Reply With Quote
  #2 (permalink)  
Old 11-15-2007
Brad
 
Posts: n/a
Default RE: [PHP] Cannot send a hyperlink

Thank you so much!

It worked like a champ first try!
I would have never seen that and have been looking everywhere on the net for
a working example!

Funny thing is, right after is work perfectly twice, my database crashed!

But, this is the technology we play with!

Problem solved and I am going to post this code on the php website for
others to reference!

Thank you!

-----Original Message-----
From: Stut [mailto:stuttle@gmail.com]
Sent: Thursday, November 15, 2007 10:16 AM
To: Brad
Cc: php-general@lists.php.net
Subject: Re: [php] Cannot send a hyperlink

Brad wrote:
> No access to the server command line to install it!
> And, I am into this guy too deep to switch technologies. For the next time
> around, no problem, this time I am just trying to get php to do what it is
> supposed to do.


You don't need command line access to install it. PHPMailer consists of
PHP only - nothing to install but PHP files. See here:
http://phpmailer.sourceforge.net/install.php

> The suggestion of mime was presented to me from another kind sole trying

to
> help that knows more than I and recommended on other help files.
>
> Why is php refusing to parse as html?


And here lies the basic problem. PHP is *not* the thing that's refusing
to parse it as HTML. Since you don't know that you really should do a
lot of reading before you try sending HTML emails without using
something like PHPMailer.

For beeps and farts I've "fixed" your code, but even though it will now
"work" it is nowhere near the right way to send this type of email, but
my life is probably going to be too short to tell you what you could
easily find out yourself.

$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 .= 'X-Mailer: PHP '.phpversion().$eol;
$headers .= 'Content-Type: text/html; charset=iso-8859-1'.$eol;
$headers .= 'Content-Transfer-Encoding: 8bit';
$subject = 'This is my spam, worship me';
$body = '<a href="http://www.zoneofsuccessclub.com/">link</a>';
mail($email, $subject, $body, $headers);

Some *important* notes...

* I defined $subject because it tries to use it.
* You don't need to provide the MessageID - your mail server will do
that for you... correctly.
* You don't need to add two carriage returns at the end of the headers -
PHP will do that for you.
* This email will be in HTML only which makes it a lot more likely to
get flagged as spam.
* If you're on a unix-based platform you really should be using the 5th
parameter to mail, but that's probably going to confuse the hell out of
you so I won't mention it. D'oh!
* This code is not secure. It's trivial to inject headers (and a body
too) into the message. You should be validating that $_REQUEST['email']
is a valid email address and just a valid email address.

-Stut

--
http://stut.net/

> -----Original Message-----
> From: Stut [mailto:stuttle@gmail.com]
> Sent: Thursday, November 15, 2007 9:46 AM
> To: Brad
> Cc: 'Daniel Brown'; 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?
>>
>> $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";
>> mail($email, $subject, $body, $headers);

>
> You should not have a mime boundary in your headers. Why not use
> PHPMailer? All this (apparently) complicated stuff is already
> implemented for you. Either that or spend a few days learning about the
> structure of emails by following the links Daniel Brown sent you a few
> emails ago.
>
> PHPMailer can be found here: http://phpmailer.sf.net/
>
> -Stut
>


No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.503 / Virus Database: 269.15.32/1131 - Release Date: 11/14/2007
4:54 PM


No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.503 / Virus Database: 269.15.32/1131 - Release Date: 11/14/2007
4:54 PM

Reply With Quote
  #3 (permalink)  
Old 11-15-2007
Dimiter Ivanov
 
Posts: n/a
Default Re: [PHP] Cannot send a hyperlink

On Nov 15, 2007 5:34 PM, Brad <brads@ftnco.com> wrote:
> Thank you so much!
>
> It worked like a champ first try!
> I would have never seen that and have been looking everywhere on the net for
> a working example!
>
> Funny thing is, right after is work perfectly twice, my database crashed!
>
> But, this is the technology we play with!
>
> Problem solved and I am going to post this code on the php website for
> others to reference!
>
> Thank you!
>


I think there is already a good example of sending mails with html :
http://php.net/manual/en/function.mail.php
Reply With Quote
  #4 (permalink)  
Old 11-15-2007
Brad
 
Posts: n/a
Default RE: [PHP] Cannot send a hyperlink

Not a single reference to sending a hyperlink on that page!

-----Original Message-----
From: Dimiter Ivanov [mailto:erazorbg@gmail.com]
Sent: Thursday, November 15, 2007 11:27 AM
To: Brad
Cc: Stut; php-general@lists.php.net
Subject: Re: [php] Cannot send a hyperlink

On Nov 15, 2007 5:34 PM, Brad <brads@ftnco.com> wrote:
> Thank you so much!
>
> It worked like a champ first try!
> I would have never seen that and have been looking everywhere on the net

for
> a working example!
>
> Funny thing is, right after is work perfectly twice, my database crashed!
>
> But, this is the technology we play with!
>
> Problem solved and I am going to post this code on the php website for
> others to reference!
>
> Thank you!
>


I think there is already a good example of sending mails with html :
http://php.net/manual/en/function.mail.php

No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.503 / Virus Database: 269.15.32/1131 - Release Date: 11/14/2007
4:54 PM


No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.503 / Virus Database: 269.15.32/1131 - Release Date: 11/14/2007
4:54 PM

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 01:19 AM.


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