/    Sign up×
Community /Pin to ProfileBookmark

Want to send email

Hi,
This is a page on my site to send PMs to members. I want the page to email the person who has just recieved a PM. Please help!

[QUOTE]

<?php
include(“./admin/config.php”);
include(“$include_path/common.php”);
include(“$include_path/pm_check.php”);

global $HTTP_POST_VARS,$HTTP_GET_VARS,$HTTP_SESSION_VARS;

global $_SESSION;

if ($HTTP_POST_VARS!=””)
$_POST=$HTTP_POST_VARS;

if ($HTTP_GET_VARS!=””)
$_GET=$HTTP_GET_VARS;

if ($HTTP_SESSION_VARS!=””)
$_SESSION=$HTTP_SESSION_VARS;

check_user_login();

include(“$include_path/$table_file”);
include(“$include_path/doc_head.php”);
include(“$include_path/styles.php”);

if(!isset($_POST[‘submit_message’]) && !isset($_GET[‘i’])){
header(“Location: $base_url/”);
exit();
}

$user_id = isset($_GET[‘i’]) ? $_GET[‘i’] : 0;

$i = 0;
$error = false;
$subject_msg = “”;
$post_msg = “”;
$reply_subject = “”;
$reply_post = “”;
$preview_content = “”;
$quoted = “”;
$resubject = “”;

if(isset($_POST[‘submit_message’])){

if(!isset($_POST[‘i’])){
header(“Location: $base_url/”);
exit();
} else {
$user_id = $_POST[‘i’];
}

if(!strlen($_POST[‘reply_subject’])){
$error = true;
$subject_msg = “<br>No subject submitted.”;
} else {
$reply_subject = $_POST[‘reply_subject’];
}

if(strlen($_POST[‘reply_post’])){
if(strlen($_POST[‘reply_post’]) > 4096){
$length = strlen($_POST[‘reply_post’]) – 4096;
$error = true;
$post_msg = “<br>4K or less. ” . $length . ” bytes too large.”;
} else {
$reply_post = $_POST[‘reply_post’];
}
} else {
$error = true;
$post_msg = “<br>No message submitted.”;
}

if(!$error){

// $reply_subject=addslashes($reply_subject);
// $reply_post=addslashes($reply_post);

insert_private_message($user_id, $reply_subject, $reply_post, $_SESSION[‘userid’]);
header(“Location: $base_url/my_messages.php?i=$user_id”);
exit();
}

}

$final_output .= <<<FO
</head>
<body bgcolor=”$page_bg_color” leftmargin=”0″ topmargin=”0″ marginwidth=”0″ marginheight=”0″ >
<table border=”0″ cellpadding=”0″ cellspacing=”0″ width=”100%” align=”center”>
<tr>
<td colspan=”3″ width=”100%” valign=”bottom”>
<table border=”0″ cellpadding=”0″ cellspacing=”0″ width=”100%”>
<tr>
<td align=”right” valign=”bottom”>
FO;

// include (“Ads_new.php”);
include (“header.php”);

$final_output .= <<<FO
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width=”20%” valign=”top”>
FO;

include(“$include_path/left.php”);

$final_output .= <<<FO
</td>
<td width=”80%” valign=”top”>
FO;
include(“$include_path/show_user_links.php”);
$title = “Private Message”;
$uid = $_SESSION[‘userid’];
$check_blocked = check_user_blocked($uid,$user_id);

IF($check_blocked == 0){

$content = <<<EOF

EOF;

$comment_user_name = get_username($user_id);
$p_user=$comment_user_name;

if(check_approved_image($user_id)){
$comment_user_name = <<<EOF
<a class=”bold” href=”$base_url/?i=$user_id”>$comment_user_name</a>
EOF;

}

$content .= <<<EOF
<table cellpadding=”3″ cellspacing=”0″ border=”0″ width=”100%”>
<tr>
<td class=”bold” align=”right”>Leave Private Message For: $comment_user_name&nbsp;</td>
</tr>
<tr>
<td class=”regular”>
EOF;

if($p_user == $_SESSION[username]) {
$comment_reply_table = <<<EOF
<table cellpadding=”3″ cellspacing=”1″ border=”0″ width=”100%”>
<tr>
<input type=”hidden” name=”i” value=”$user_id”>
<td class=”bold-rv” colspan=”2″>&nbsp;Leave Private Message</td>
</tr>
<tr class=”alt1″>
<td class=”regular” colspan=”2″ align=”left”>You cannot send Private Message to yourself.</td>
</tr>
</table>
EOF;
}
else {
$comment_reply_table = <<<EOF
<table cellpadding=”3″ cellspacing=”1″ border=”0″ width=”100%”>
<tr><form method=”post” action=”$base_url/message.php”>
<input type=”hidden” name=”i” value=”$user_id”>
<td class=”bold-rv” colspan=”2″>&nbsp;Leave Private Message</td>
</tr>
<tr class=”alt2″>
<td class=”regular” align=”right”>Logged in as:</td>
<td class=”regular”><a href=”$base_url/?i=$_
SESSION[userid]”>$_SESSION[username]</a></td>
</tr>
<tr class=”alt1″>
<td class=”regular” align=”right”>Subject:</td>
<td class=”regular”><input class=”input” type=”text” name=”reply_subject” size=”67″ value=”$reply_subject”><span class=”error”>$subject_msg</span></td>
</tr>
<tr class=”alt1″>
<td class=”regular” align=”right” valign=”top”><br>Message:</td>
<td class=”regular”><textarea class=”input” name=”reply_post” rows=”16″ cols=”70″ wrap=”virtual”>$reply_post</textarea><span class=”error”>$post_msg</span></td>
</tr>
<tr class=”alt2″>
<td class=”regular” align=”center” colspan=”2″ nowrap><input class=”button” type=”submit” name=”submit_message” value=”Leave Private Message”></td>
</form></tr>
</table>
EOF;
}

$content .= table_no_title($comment_reply_table);

$content .= <<<EOF
</td>
</tr>
</table>
EOF;

}
ELSE
{
$content = <<<EOF
<br><br>Sorry this user has blocked you, therefore you cannot contact them<br><br><br>
EOF;
}

$final_output .= table($title, $content);

$final_output .= <<<FO
</td>
</tr>
</table>
FO;
include(“$include_path/footer.php”);
$final_output .= $contents;

$final_output .= <<<FO
</body>
</html>
FO;

echo $final_output;

?>

[/QUOTE]

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@squallflightAug 08.2004 — Just use the mail() function
[code=php]
//receptant
$to = 'whoever@whereever';
//email subject
$subject = 'New Private Message';
//email message
$message = $receptantsName.', You have just been sent a Private Message from: '.$sendersName.'n
You can check your private messages here:n
http://www.yourdomain.com/<PM INBOX>';
//extra headers
$xHeaders = 'From: [email protected]
X-Mailer: PHP/'.phpversion();

//send the email
mail($to, $subject, $message, $xHeaders);

[/code]

Stick this at the stage of your code where you want to send the email.

btw: You should get into the habit of commenting your code like I have otherwise if you where to leave it for a week or more then come back you could get lost in your own code. always comment! trust me I know.? when I first started coding in PHP i didn't use comments then as I got better I revised what I had done to see if I could improve from it...It took me ages to understand what I'd done.

note: the $xHeaders part of the mail function is optional.
Copy linkTweet thisAlerts:
@wsloverauthorSep 16.2004 — Thanks! I'll give this a try and let you know

Bill
Copy linkTweet thisAlerts:
@wsloverauthorSep 16.2004 — What functions and command would I use to call in the recievers email address?
×

Success!

Help @wslover spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...