 |
 |
 |
 |
 |
| Author |
Message |
ksen

Joined: 04 Jun 2006 Posts: 142
|
|
|
|
YIPPY!!! it works
OK i finally got it to email the link to the article. I didnt try the full story yet. But now i have something to work on!! Thanx so much for ur help fi-dd. Will kp u updated on progress of the full story mail k.
Thanx again.
|
|
| Tue Sep 26, 2006 2:36 am |
|
 |
Guest
|
|
|
Please login to hide the ads.
|
|
|
|
 |
ksen

Joined: 04 Jun 2006 Posts: 142
|
|
|
|
hey fi-dd,
thanx so much for ur support!! I'm getting the a url for the article and the full story sent in the email
I had to modify a little the code snippet u gave me to get it working on mine. i dont know why i had to modify it to get it working buti did and it working fine now
Abit more help needed tho, I want to have the title of the article also in the email.
Does this bit of code capture the title as well??
 |  | $story = reset(
$sql->select(array(
'table' => 'story',
'where' => array("post_id = ".$_POST['article_id'])
))); |
Can i simply add the following to do that??
 |  | $message = str_replace({title}, replace_news('admin', $story['title']), $message); |
Well to be honest i tried it and it didnt work!!
Thanx
|
|
| Sat Sep 30, 2006 7:36 am |
|
 |
FI-DD
Admin

Joined: 22 Sep 2005 Posts: 2801 Location: Germany |
|
|
|
The title is in a different table:
 |  | $news = reset(
$sql->select(array(
'table' => 'news',
'where' => array("id = ".$_POST['article_id'])
)));
$message = str_replace({title}, replace_news('admin', $news['title']), $message);
|
|
|
| Sat Sep 30, 2006 1:21 pm |
|
 |
ksen

Joined: 04 Jun 2006 Posts: 142
|
|
Mission Accomplished !! |
|
Whew!! I'm finally done
1. Th script now email the artcle to a friend in the following format
 |  | Hello ksen,
Following is an interesting article:
Please check it out yourself.
Best regards,
Sender.
---------------------------------------------------------
Title Of News Article
Full Story Here Full Story Here Full Story Here Full Story Here
Full Story Here Full Story Here Full Story Here Full Story Here
Full Story Here Full Story Here Full Story Here Full Story Here
Full Story Here Full Story Here Full Story Here Full Story Here
Full Story Here Full Story Here Full Story Here Full Story Here
Full Story Here Full Story Here Full Story Here Full Story Here
Full Story Here Full Story Here Full Story Here Full Story Here
Full Story Here Full Story Here Full Story Here Full Story Here
Full Story Here Full Story Here Full Story Here Full Story Here
Click here to read the original article |
2. There were a considerable bit of little little changes to the code. (not to the logic but with tags and variables and how the data was captured).
3. I have also formatted the data entry page whr the senders and recievers details are input and made it look attractive.
4. Well here is the code for anyone interested..
 |  | <?php
include('head.php');
if($_POST['dosend'] == "yes"){
//Config subject
$subject = "Interesting article from web site";
//Config message
$message = "<table width='630' border='0' cellspacing='0' cellpadding='15' style='font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px;'> <tr> <td>";
$message .= "Hello {friend},<br /><br />";
$message .= "Following is an interesting article in the web site:<br />";
$message .= "Please check it out yourself. <br/><br/>";
$message .= "Best regards,<br />{sendername}<br /><br /><hr><br /><br />";
$message .= "<strong>{title}</strong><br /><br />{full-story}</td></tr>";
$message .= "<tr><td><a href='{url}'>Click here to read the original article
</a> </td></tr></table>";
//Config mail
$mail_from = $_POST['sendermail'];
//
$friend = $_POST['recipientname'];
$mail = $_POST['recipientmail'];
$sendername = $_POST['sendername'];
$id = $_POST['article_id'];
$error = false;
if($friend == "" or $mail == ""){
$error = "Error! At least one field is empty. Please go back and fill out all the fields.";
}
$news = reset(
$sql->select(array(
'table' => 'news',
'where' => array("id = ".$article_id)
)));
$story = reset(
$sql->select(array(
'table' => 'story',
'where' => array("post_id = ".$article_id)
)));
$message = str_replace("{friend}", $friend, $message);
$message = str_replace("{title}", replace_news('admin', $news['title']), $message);
$message = str_replace("{url}", 'http://www.mydomainname/cn/fullstory.php?id='.$article_id, $message);
$message = str_replace("{full-story}", replace_news('admin', $story['full']), $message);
$message = str_replace("{sendername}", $sendername, $message);
$headers = 'From: '.$mail_from."\n";
$headers .= 'Reply-to: '.$mail_from."\n";
$headers .= 'Return-Path: '.$mail_from."\n";
$headers .= 'Message-ID: <'.md5(uniqid(time())).'@'.$_SERVER['SERVER_NAME'].">\n";
$headers .= 'MIME-Version: 1.0'."\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= 'Date: '.gmdate('D, d M Y H:i:s', time())."\n";
$headers .= 'X-Priority: 3'."\n";
$headers .= 'X-MSMail-Priority: Normal'."\n";
if(mail($mail, $subject, $message, $headers)){
echo "Thank you.<br />";
echo "The message was sent to ".$friend." (".$mail.")<br /><br />";
// echo $message;
echo "<br/>";
echo '<a href="javascript:window.close();">Close window</a>';
}
else echo $error;
}
else{
?>
<table border="0" align="center" cellpadding="15" cellspacing="0" style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px; border:1px solid #0033FF;">
<tr>
<td style="border-bottom:1px solid #0033FF; background-color:#9289F5;"><strong>E-Mail News Article </strong></td>
</tr>
<tr>
<td><form action="" method="post">
<table style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px;">
<tr>
<td>Senders Name</td>
<td> </td>
<td>:</td>
<td> </td>
<td><input type="text" name="sendername"></td></tr>
<tr>
<td>Senders E-mail</td>
<td> </td>
<td>:</td>
<td> </td>
<td><input type="text" name="sendermail"></td></tr>
<tr>
<td>Recipient's Name</td>
<td> </td>
<td>:</td>
<td> </td>
<td><input type="text" name="recipientname"></td></tr>
<tr><td><p>Recipient's E-mail</p>
</td>
<td> </td>
<td>:</td>
<td> </td>
<td><input type="text" name="recipientmail"></td></tr>
<tr>
<td colspan="5"> </td>
</tr>
<tr>
<td colspan="5" align="center"><input type="submit" value="E-Mail Article" /></td>
</tr>
<input type="hidden" name="dosend" value="yes">
<input type="hidden" name="url" value="<? echo $_POST['url'];?> ">
</table>
</form> </td>
</tr>
</table>
<?
}
?> |
|
|
| Sun Oct 01, 2006 3:22 pm |
|
 |
ksen

Joined: 04 Jun 2006 Posts: 142
|
|
|
|
By the way, thank you so much for ur wonderful help fi-dd!!
Could never have been able to do this without ur help
Thanx maan, keept up the good work
Ksen
|
|
| Sun Oct 01, 2006 3:27 pm |
|
 |
nam

Joined: 23 Dec 2006 Posts: 120
|
|
need help with the script |
|
I successfully installed the script “mail to friend” and its works fine.
But I need few changes in the way news are sent in the emails but as I am new in PHP can’t figure out how to do it, here are things I want to do and need help with it:
- I want to include something like this in the top of the article sent to the email: <b>[xfvalue_newsource]</b>, {date}
- I want to send only “short story” in the email and then put a link to the full story on the bottom of it but <a href="{link=home/post}">{title}</a> does not work in it.
- I want the name of the sender to be started with a capital letter even if the user enters all in small caps. I mean if someone enters his name as “xyz” it should appear in the email as “Xyz”.
- How to send the Print version of the article to the email? I mean {link=print/post} should work in it.
- Why {cutepath} does not work in it? I have to enter the full URL which is not a good way to do thing, so please guide me to generalize the script.
Thanks for your help in advance.
 |  |
<?php
include('head.php');
if($_POST['dosend'] == "yes"){
//Config subject
$subject = "News item from web site";
//Config message
$message = "<table width='95%' border='0' cellspacing='0' cellpadding='15' style='font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px;'> <tr> <td>";
$message .= "Hello {friend},<br /><br />";
$message .= "Following is a news item.<br /><br />";
$message .= "Please check it out yourself and if interested. <br/><br/>";
$message .= "Best regards,<br />{sendername}<br /><br /><hr><br /><br />";
$message .= "<strong>{title}</strong><br /><br />{short-story}</td></tr>";
$message .= "<tr><td><a href='{url}'>Click here to read the full story</a> </td></tr></table>";
//Config mail
$mail_from = $_POST['sendermail'];
//
$friend = $_POST['recipientname'];
$mail = $_POST['recipientmail'];
$sendername = $_POST['sendername'];
$id = $_POST['article_id'];
$error = false;
if($friend == "" or $mail == ""){
$error = "Error! At least one field is empty. Please go back and fill out all the fields.";
}
$news = reset(
$sql->select(array(
'table' => 'news',
'where' => array("id = ".$article_id)
)));
$story = reset(
$sql->select(array(
'table' => 'story',
'where' => array("post_id = ".$article_id)
)));
$message = str_replace("{friend}", $friend, $message);
$message = str_replace("{title}", replace_news('admin', $news['title']), $message);
$message = str_replace("{url}", 'http://www.something.com/cutenews/news.php?id='.$article_id, $message);
$message = str_replace("{short-story}", replace_news('admin', $story['full']), $message);
$message = str_replace("{sendername}", $sendername, $message);
$headers = 'From: '.$mail_from."\n";
$headers .= 'Reply-to: '.$mail_from."\n";
$headers .= 'Return-Path: '.$mail_from."\n";
$headers .= 'Message-ID: <'.md5(uniqid(time())).'@'.$_SERVER['SERVER_NAME'].">\n";
$headers .= 'MIME-Version: 1.0'."\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$message .= "<link href='http://www.something.com/cutenews/news.css' rel=stylesheet type=text/css >\n";
$headers .= 'Date: '.gmdate('D, d M Y H:i:s', time())."\n";
$headers .= 'X-Priority: 3'."\n";
$headers .= 'X-MSMail-Priority: Normal'."\n";
if(mail($mail, $subject, $message, $headers)){
echo "<font color=#3D5C87 size=2 face=Arial>Thank you.<br />";
echo "<font color=#3D5C87 size=2 face=Arial>The message was sent to ".$friend." (".$mail.")<br /><br />";
// echo $message;
echo "<br/>";
echo '<font color=#3D5C87 size=2 face=Arial><a href="javascript:window.close();">Close window</a>';
}
else echo $error;
}
else{
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>E-Mail News Article</title>
<SCRIPT LANGUAGE="JavaScript">
function fixElement(element, message)
{
alert(message);
element.focus();
}
function isMailReady(form1)
{
var passed = false;
if (form1.sendername.value == "")
{
fixElement(form1.sendername, "Please include your name.");
}
else if (form1.sendermail.value.indexOf("@") == -1 || form1.sendermail.value.indexOf(".") == -1)
{
fixElement(form1.sendermail, "Please include your proper email address.");
}
else if (form1.recipientmail.value.indexOf("@") == -1 || form1.recipientmail.value.indexOf(".") == -1)
{
fixElement(form1.recipientmail, "Please include a proper email address of the recipient.");
}
else if (form1.recipientname.value == "")
{
fixElement(form1.recipientname, "Please enter the recipient name.");
}
else {
passed = true; form1.submit.disabled=true;
}
return passed;
}
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
function EmailValid()
{
var str=form1.recipientmail.value;
len=str.length;
e1=false;e2=false
for(i=1; i<len; i++)
{
if(str.charAt(i)=="@")
e1=true
if(str.charAt(i)==".")
e2=true
}
if (e1 && e2)
return true;
form1.recipientmail.focus();
alert("Recipient Email Address is Invalid, try again");
return false;
}
</SCRIPT>
</head>
<body>
<div align="center">
<table border="0" cellpadding="10" cellspacing="0" style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px; border:1px solid #9AB1D1;">
<tr>
<td style="border-bottom:1px solid #9AB1D1; background-color:#9AB1D1;">
<p align="center"><b>
<font color="#FFFFFF" size="3" face="Arial">E-Mail News Article</font></b></td>
</tr>
<tr>
<td bgcolor="#EEF1F7"><form action="" method="post" name="form1" onSubmit="return isMailReady(this);">
<table style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px;" cellspacing="1">
<tr>
<td><font color="#3D5C87">Your Name</font></td>
<td width="10"> </td>
<td><input type="text" name="sendername" style="border:1px solid #8EA9CC; font-family: Verdana; font-size: 10pt; color: #3D5C87; background-color:#F8F9FC" size="20"></td></tr>
<tr>
<td><font color="#3D5C87">Your E-mail</font></td>
<td width="10"> </td>
<td><input type="text" name="sendermail" style="border:1px solid #8EA9CC; font-family: Verdana; font-size: 10pt; color: #3D5C87; background-color:#F8F9FC" size="20"></td></tr>
<tr>
<td><font color="#3D5C87">Recipient's Name</font></td>
<td width="10"> </td>
<td><input type="text" name="recipientname" style="border:1px solid #8EA9CC; font-family: Verdana; font-size: 10pt; color: #3D5C87; background-color:#F8F9FC" size="20"></td></tr>
<tr><td><p><font color="#3D5C87">Recipient's E-mail</font></p>
</td>
<td width="10"> </td>
<td><input type="text" name="recipientmail" style="border:1px solid #8EA9CC; font-family: Verdana; font-size: 10pt; color: #3D5C87; background-color:#F8F9FC" size="20" onChange="EmailValid()"></td></tr>
<tr>
<td colspan="3" align="center">
<input type="submit" id="submit" value="Send" style="font-family: Verdana; font-size: 10pt; color: #0000FF; margin-top:5px;" /></td>
</tr>
<input type="hidden" name="dosend" value="yes">
<input type="hidden" name="url" value="<? echo $_POST['url'];?>">
<input type="hidden" name="short-story" value="<? echo $_POST['{short-story}'];?>">
</form>
</table>
</td></tr>
</table>
</div>
</body>
</html>
<?
}
?>
|
|
|
| Fri Dec 29, 2006 4:58 pm |
|
 |
hetes

Joined: 17 Apr 2007 Posts: 36 Location: Hungary |
|
|
|
I have tried all the codes above, but it doesnt send the story's url and the full story...
Cud sy help me? 
|
|
| Sun Apr 22, 2007 6:49 pm |
|
 |
flyboy17
Joined: 21 Feb 2007 Posts: 49
|
|
|
|
I tried the code from FI-DD.
Everything works!
But when 'the friend' receive the message, there will be no link to the news-item in the message.
is this a standalone problem or is something wrong with "$message = str_replace("{url}", $url, $message);" ?
I tried firefox and Internet explorer but without succes.
Is the url not showing because the new window (the mail-to-friend link) is a javascript window without linking url?
|
|
| Mon Apr 23, 2007 6:13 pm |
|
 |
FI-DD
Admin

Joined: 22 Sep 2005 Posts: 2801 Location: Germany |
|
|
|
Try changing this:
 |  | $message = str_replace("{url}", $url, $message); |
to this:
 |  | $message = str_replace("{url}", $_GET['url'], $message); |
|
|
| Mon Apr 23, 2007 6:28 pm |
|
 |
hetes

Joined: 17 Apr 2007 Posts: 36 Location: Hungary |
|
|
|
 |  | Try changing this:
 |  | $message = str_replace("{url}", $url, $message); |
to this:
 |  | $message = str_replace("{url}", $_GET['url'], $message); |
|
Great, it's perfect!
Thx FI-DD! 
|
|
| Mon Apr 23, 2007 8:41 pm |
|
 |
flyboy17
Joined: 21 Feb 2007 Posts: 49
|
|
|
|
This little change works!
Thanks 
|
|
| Mon Apr 23, 2007 9:00 pm |
|
 |
gauss

Joined: 06 Sep 2006 Posts: 23
|
|
? |
|
It is work for mine just fine, but I donot get any link to post or article???
|
|
| Tue Apr 24, 2007 10:41 am |
|
 |
flyboy17
Joined: 21 Feb 2007 Posts: 49
|
|
|
|
Just read the last 3 posts...
|
|
| Wed Apr 25, 2007 8:59 pm |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|
 |
 |
 |
|