Page 1 of 1
Calling HREF from PHP - using mail() ..how to ???
Posted: Wed Oct 22, 2008 6:02 pm
by soulmasta
Hello i have one more question this time is having to do with mail() function .
Thus i have this :
Code: Select all
mail("$theemail","$thesubject","$thevarforhttp");
and supose that as $thevarforhttp i want to pass this stuff :
Code: Select all
<a href="http://www.site.com/page.php?mytext=$varone&mysignature=$var2">Clik_here</a>
so that
Code: Select all
$thevarforhttp = '<a href="http://www.site.com/page.php?mytext=$varone&mysignature=$var2">Click_here</a>'
then which is the right way to write it , cause as i wrote it , the HREF is not working
and so i cant get Click_here as a link .
Am just getting the link ... i think is reason of the quotes '' " '" etc..
So which is the right to way to fix this stuff so that will be visible only Click_here and NOt the whole dam link ?
Thanks in advance..
Re: Calling HREF from PHP - using mail() ..how to ???
Posted: Wed Oct 22, 2008 6:20 pm
by Syntac
You may need to have mail() set a header... Something like "Content-type: text/html", maybe?
Re: Calling HREF from PHP - using mail() ..how to ???
Posted: Wed Oct 22, 2008 6:24 pm
by soulmasta
so if i will add a $header then Click_here will be an active link and will not appear anymore as text ?
Re: Calling HREF from PHP - using mail() ..how to ???
Posted: Wed Oct 22, 2008 6:44 pm
by Syntac
From
mail():
Code: Select all
<?php
// multiple recipients
$to = 'aidan@example.com' . ', '; // note the comma
$to .= 'wez@example.com';
// subject
$subject = 'Birthday Reminders for August';
// message
$message = '
<html>
<head>
<title>Birthday Reminders for August</title>
</head>
<body>
<p>Here are the birthdays upcoming in August!</p>
<table>
<tr>
<th>Person</th><th>Day</th><th>Month</th><th>Year</th>
</tr>
<tr>
<td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
</tr>
<tr>
<td>Sally</td><td>17th</td><td>August</td><td>1973</td>
</tr>
</table>
</body>
</html>
';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";
// Mail it
mail($to, $subject, $message, $headers);
?>
So just add a header with "Content-type: text\html\r\n" and it should work (note: the "\r\n" part is probably necessary).
Re: Calling HREF from PHP - using mail() ..how to ???
Posted: Wed Oct 22, 2008 6:56 pm
by soulmasta
ok chief thanks a lot, i added that and it worked all right !
just now am facing an other problem .
before into my mail() function i used also one more var $from , which it was telling the reciever of the email about my email adress par example
mymail@mydomain.com .
After that i added the $header as you said and worked , i realize that if i have 5 elements as :
Code: Select all
mail("$theemail","$thesubject","$thehttp","$headers","$from");
am getting this Error :
SAFE MODE Restriction in effect. The fifth parameter is disabled in SAFE MODE
i cant have 5 parameters on my mail() function ?
Note that when i removed the $from my firth parameter variable then as you told me before worked ...
hmm..
because i would like to have also this $from so the reciever of the email to know who am , how we can fix this ?
Now instead of $from =
mymail@mydomain.com;
in the email that am recieving is written there the domain address of my hosting company
can we fix this new problem ? and how plz ?
Re: Calling HREF from PHP - using mail() ..how to ???
Posted: Wed Oct 22, 2008 7:32 pm
by Syntac
Don't use the fifth parameter. Either that or turn safe mode off.
Re: Calling HREF from PHP - using mail() ..how to ???
Posted: Wed Oct 22, 2008 7:41 pm
by soulmasta
ok am on
hosting anyway ( i cant turn off safe mode )
just if i cant use a 5th parameter on mail() reason of safe mode,
then can i add somewhere on $headers a variable $from
where $from =
myemail@me.com ?
Look,
i tried this one :
Code: Select all
$headers .= "Content-type: text/html; charset=UTF-8; From: <" . $from . ">\r\n";
but again the email it came to me using the hosting's email address
anonym@hosting.com
..can we somehow add this $from variable into headers , yes or no ?
it is possible ? if yes then which is the right way, syntax ?
Re: Calling HREF from PHP - using mail() ..how to ???
Posted: Wed Oct 22, 2008 8:35 pm
by Syntac
Code: Select all
$headers .= "Content-type: text/html; charset=UTF-8\r\nFrom: Random guy <myemail@me.com>\r\n";
Separate HTTP headers from mail headers with "\r\n", not ";".
P.S. My name is not "syntax"!