Anonymous Email
Moderator: General Moderators
Anonymous Email
Hi,
I want to send anonymous email to anyone and receive private replies in their own inbox.
Any Idea how to do this.
Thanks,
Lokesh.
I want to send anonymous email to anyone and receive private replies in their own inbox.
Any Idea how to do this.
Thanks,
Lokesh.
I have no idea what you just said. You lost me at the private replies bit.
You can send an email so:
Hotmail and others don't like sendmail, though. An alternative is phpmailer.
You can send an email so:
Code: Select all
mail($to, $subject, $message, $headers);
//e.g.
mail("anyone@somewhere.net",$sub,$msg,"From: anonymous@nowhere.net\nReply-To: anonymous@nowhere.net");Re: Anonymous Email
Can't. All emails have *some* level of accountability. You can make it so that its limited to "From this server", or "From this service", but can't really get truly anonymous. To do so, simply send it from theserver@example.com or whatever group mail account you like.lokesh wrote:Hi,
I want to send anonymous email to anyone
Simply set the reply-to field to the user's email address.lokesh wrote:receive private replies in their own inbox.
you could set the reply-to header to an email address you create for them, and so if they hit reply, it would then send an email to that address. You could then have php pop to your mail server and grab the emails for those specific addresses and output it on an html page in their own "private" section.
let me know if you need any help with any of that, I recently did a project that did jsut that.
let me know if you need any help with any of that, I recently did a project that did jsut that.
For receiving private replies in their own inbox....
If user reply to anon-001@domain.com, email should go to clients own inbox...
Lokesh.
If user reply to anon-001@domain.com, email should go to clients own inbox...
Lokesh.
- shiznatix
- DevNet Master
- Posts: 2745
- Joined: Tue Dec 28, 2004 5:57 pm
- Location: Tallinn, Estonia
- Contact:
Code: Select all
mail($users_email, $subject, $messsage, "From: anonymous@nowhere.net\nReply-To: anonymous@nowhere.net");Sorry this took so long to get to you...crazy meeting!
here are a couple of functions you can use to pop to a mail server and retreive mail *Note requires PEAR (don't know who originally authored them so can't give credit...sorry. I do know that I've completely butchered them to make sure they worked for me
):
you're going to need to include two files from PEAR:
here are a couple of functions you can use to pop to a mail server and retreive mail *Note requires PEAR (don't know who originally authored them so can't give credit...sorry. I do know that I've completely butchered them to make sure they worked for me
you're going to need to include two files from PEAR:
Code: Select all
// you need to set the constants...obviously
<?php
require_once('../includes/pop3.php');
require_once('Mail/mimeDecode.php'); //PEAR Mail_Mime Module
require_once('Mail/RFC822.php'); // PEAR Mail Module
error_reporting(E_ERROR);
set_error_handler("e;emailErrorHandler"e;);
tt_db_connect();
mysql_query("e;LOCK TABLE ttpop3last WRITE"e;);
$getlastsql = "e;SELECT lastretrieved FROM ttpop3last"e;;
$getlasthandle = mysql_query($getlastsql)
or trigger_error("e;Couldn't get last email time."e;, E_USER_ERROR);
$getlast = mysql_fetch_row($getlasthandle);
if (!$getlast || strtotime($getlastї0]) + POP3_WAIT <= time())
{
$updatelastsql = $getlast ? "e;UPDATE ttpop3last SET lastretrieved=NOW()"e; : "e;INSERT INTO ttpop3last (lastretrieved) VALUES (NOW())"e;;
mysql_query($updatelastsql);
mysql_query("e;UNLOCK TABLES"e;);
$handle = pop3_connect(POP3_SERVER, POP3_PORT, POP3_USER, POP3_PASS, POP3_APOP)
or trigger_error("e;Couldn't connect to pop3 server. Details: {$errstr}"e;, E_USER_ERROR);
$stats = pop3_stat($handle)
or trigger_error("e;Couldn't execute stat command. Details: {$errstr}"e;, E_USER_ERROR);
if ($statsї'count'] > 0)
{
if ($messages = pop3_uidl($handle))
$uidlist = TRUE; //we have a unique id for each message now
else
{
$uidlist = FALSE; //we do not have a unique id for each message yet
$messages = pop3_list($handle)
or trigger_error("e;Couldn't retrieve message list. Details: {$errstr}"e;, E_USER_ERROR);
}
foreach($messages as $msgid => $extrainfo)
{
if (!$uidlist)
{
//don't want to retrieve extra messages unless we need to
$message = pop3_retr($handle, $msgid);
$messageuid = md5(implode('', $message));
}
else
{
$messageuid = trim($extrainfo);
}
$isuniquehandle = mysql_query("e;SELECT COUNT(id) FROM mailtable WHERE mailid='{$messageuid}'"e;)
or trigger_error("e;Couldn't select unique IDs."e;, E_USER_ERROR);
$isunique = mysql_fetch_row($isuniquehandle);
if ($isuniqueї0] == 0)
{
if ($uidlist)
{
if (($message = pop3_retr($handle, $msgid)) === FALSE) //retrieve message now since it wasn't done above
{
//we don't want to break the loop, there may just be something wrong with this message
continue;
}
}
$params = array();
$paramsї'include_bodies'] = true;
$paramsї'decode_bodies'] = true;
$paramsї'decode_headers'] = true;
$paramsї'input'] = implode('', $message);
$structure = Mail_mimeDecode::decode($params);
$subject = isset($structure->headersї'subject']) ? $structure->headersї'subject'] : '';
$from = $structure->headersї'from'];
$from = Mail_RFC822::parseAddressList($from, POP3_DEFHOST, FALSE, TRUE);
$from = $fromї0]->mailbox . '@' . $fromї0]->host; //don't care about extra info
$datesent = strtotime($structure->headersї'date']);
$messageid = $structure->headersї'message-id'];
$emailinfo = getEmail($structure);
if (!isset($emailinfoї'text']))
{
$emailinfoї'text'] = isset($emailinfoї'html']) ? trim(unhtmlentities(strip_tags($emailinfoї'html']))) : "e;No email content"e;;
}
if (!isset($emailinfoї'html']))
{
$emailinfoї'html'] = isset($emailinfoї'text']) ? nl2br(htmlentities($emailinfoї'text'])) : "e;No email content"e;;
}
//lokesh....run your insert queries here
if (POP3_DELETE)
pop3_delete($handle, $msgid);
mysql_free_result($isuniquehandle);
} // end foreach message
} // end if statsї'count'] > 0
pop3_quit($handle);
} //end if last time is this time
mysql_query("e;UNLOCK TABLES"e;);
header("e;Expires: Mon, 26 Jul 1997 05:00:00 GMT"e;);
// always modified
header("e;Last-Modified: "e; . gmdate("e;D, d M Y H:i:s"e;) . "e; GMT"e;);
// HTTP/1.1
header("e;Cache-Control: no-store, no-cache, must-revalidate"e;);
header("e;Cache-Control: post-check=0, pre-check=0"e;, false);
// HTTP/1.0
header("e;Pragma: no-cache"e;);
// tell it that this is a gif
header("e;Content-Type: image/gif"e;);
readFile("e;../images/spacer.gif"e;);
function emailErrorHandler($errno, $errstr, $errfile, $errline)
{
global $handle;
pop3_quit($handle);
mysql_query("e;UNLOCK TABLES"e;);
header("e;Expires: Mon, 26 Jul 1997 05:00:00 GMT"e;);
// always modified
header("e;Last-Modified: "e; . gmdate("e;D, d M Y H:i:s"e;) . "e; GMT"e;);
// HTTP/1.1
header("e;Cache-Control: no-store, no-cache, must-revalidate"e;);
header("e;Cache-Control: post-check=0, pre-check=0"e;, false);
// HTTP/1.0
header("e;Pragma: no-cache"e;);
// tell it that this is a gif
header("e;Content-Type: image/gif"e;);
readFile("e;../images/spacer.gif"e;);
exit();
}
?>Code: Select all
<?php
//pop3 stuff
$errno = '';
$errstr = '';
define('GETLENGTH', 512);
define('TIMEOUT', 200);
function pop3_connect($popserver, $popport, $username = '', $pass = '', $apop = FALSE, $echocmd = FALSE, $echortrn = FALSE)
{
global $errno, $errstr;
if (empty($username) || empty($pass))
{
$errno = -2;
$errstr = "e;Username and/or password not provided"e;;
return FALSE;
}
if ($echocmd) echo "e;CONNECTING TO {$popserver}:{$popport}\n"e;;
$handle = fsockopen($popserver, $popport, $errno, $errstr);
if (!$handle)
{
if ($echocmd) echo "e;CONNECTION FAILED\n"e;;
return $handle;
}
stream_set_blocking($handle, TRUE);
$response = fgets($handle, GETLENGTH);
$response = pop3_killcrlf($response);
if ($echortrn) echo "e;REPLY: {$response}\n"e;;
if (!pop3_isGoodReply($response))
{
if ($echocmd || $echortrn) echo "e;UNRECOGNIZED REPLY\n"e;;
pop3_quit($handle, $echocmd, $echortrn);
$errno = -2;
$errstr = "e;Server returned this unrecognized response: {$response}"e;;
return FALSE;
}
$confString = preg_replace("e;/^\+OK\s+<(.+)>/"e;, "e;\\1"e;, $response); //for apop
$command = "e;NOOP\r\n"e;;
fwrite($handle, $command, strlen($command));
if ($echocmd) echo "e;CMD: {$command}\n"e;;
$response = fgets($handle, GETLENGTH);
$response = pop3_killcrlf($response);
if ($echortrn) echo "e;REPLY: {$response}\n"e;;
if (pop3_isGoodReply($response))
{
if ($echocmd || $echortrn) echo "e;SERVER IS NOT RFC 1939 COMPLIANT\n"e;;
pop3_quit($handle, $echocmd, $echortrn);
$errno = -2;
$errstr = "e;POP3 Server did not comply with RFC 1939 for NOOP before authentication: {$response}"e;;
return FALSE;
}
if (!$apop)
{
$command = "e;USER {$username}\r\n"e;;
fwrite($handle, $command, strlen($command));
if ($echocmd) echo "e;CMD: {$command}\n"e;;
$response = fgets($handle, GETLENGTH);
$response = pop3_killcrlf($response);
if ($echortrn) echo "e;REPLY: {$response}\n"e;;
if (!pop3_isGoodReply($response))
{
if ($echocmd || $echortrn) echo "e;USERNAME DID NOT WORK\n"e;;
pop3_quit($handle, $echocmd, $echortrn);
$errno = -2;
$errstr = "e;Username did not return OK: {$response}\n"e;;
return FALSE;
}
$command = "e;PASS {$pass}\r\n"e;;
fwrite($handle, $command, strlen($command));
if ($echocmd) echo "e;CMD: {$command}\n"e;;
$response = fgets($handle, GETLENGTH);
$response = pop3_killcrlf($response);
if ($echortrn) echo "e;REPLY: {$response}\n"e;;
if (!pop3_isGoodReply($response))
{
if ($echocmd || $echortrn) echo "e;Password not authenticated\n"e;;
pop3_quit($handle, $echocmd, $echortrn);
$errno = -2;
$errstr = "e;Username or password not authenticated: {$response}\n"e;;
return FALSE;
}
}
else //apop
{
$confString .= $pass;
$confString = md5($confString);
$command = "e;APOP {$username} {$confString}\r\n"e;;
fwrite($handle, $command, strlen($command));
if ($echocmd) echo "e;CMD: {$command}\n"e;;
$response = fgets($handle, GETLENGTH);
$response = pop3_killcrlf($response);
if ($echortrn) echo "e;REPLY: {$response}\n"e;;
if (!pop3_isGoodReply($response))
{
if ($echocmd || $echortrn) echo "e;APOP LOGIN FAILED\n"e;;
pop3_quit($handle, $echocmd, $echortrn);
$errno = -2;
$errstr = "e;Apop login not authenticated: {$response}\n"e;;
return FALSE;
}
}
//now do noop again just to be sure we're authenticated and the server works
$command = "e;NOOP\r\n"e;;
fwrite($handle, $command, strlen($command));
if ($echocmd) echo "e;CMD: {$command}\n"e;;
$response = fgets($handle, GETLENGTH);
$response = pop3_killcrlf($response);
if ($echortrn) echo "e;REPLY: {$response}\n"e;;
if (!pop3_isGoodReply($response))
{
if ($echocmd || $echortrn) echo "e;SERVER IS NOT RFC 1939 COMPLIANT\n"e;;
pop3_quit($handle, $echocmd, $echortrn);
$errno = -2;
$errstr = "e;POP3 Server did not comply with RFC 1939 for NOOP after authentication: {$response}"e;;
return FALSE;
}
set_time_limit(TIMEOUT);
return $handle;
}
function pop3_stat($handle, $echocmd = FALSE, $echortrn = FALSE)
{
global $errno, $errstr;
$command = "e;STAT\r\n"e;;
fwrite($handle, $command, strlen($command));
if ($echocmd) echo "e;CMD: {$command}\n"e;;
$response = fgets($handle, GETLENGTH);
$response = pop3_killcrlf($response);
if ($echortrn) echo "e;REPLY: {$response}\n"e;;
if (!pop3_isGoodReply($response))
{
if ($echocmd || $echortrn) echo "e;Stat failed\n"e;;
$errno = -3;
$errstr = "e;Stat command failed: {$response}"e;;
return FALSE;
}
set_time_limit(TIMEOUT);
$temp = explode("e; "e;, $response);
return array("e;count"e; => intval($tempї1]), "e;length"e; => intval($tempї2]));
}
function pop3_list($handle, $msgNum = '', $echocmd = FALSE, $echortrn = FALSE)
{
global $errno, $errstr;
if (empty($msgNum))
{
$command = "e;LIST\r\n"e;;
fwrite($handle, $command, strlen($command));
if ($echocmd) echo "e;CMD: {$command}\n"e;;
$response = fgets($handle, GETLENGTH);
$response = pop3_killcrlf($response);
if ($echortrn) echo "e;REPLY: {$response}\n"e;;
if (!pop3_isGoodReply($response))
{
if ($echocmd || $echortrn) echo "e;List failed\n"e;;
$errno = -3;
$errstr = "e;List command failed: {$response}"e;;
return FALSE;
}
$messages = array();
while (preg_match("e;/^(\d+) (\d+)(.*)$/"e;, fgets($handle, GETLENGTH), $lineInfo))
{
if ($echortrn) echo "e;REPLY: {$lineInfoї0]}\n"e;;
$messagesїintval($lineInfoї1])] = intval($lineInfoї2]);
}
set_time_limit(TIMEOUT);
return $messages;
}
else
{
$command = "e;LIST {$msgNum}\r\n"e;;
fwrite($handle, $command, strlen($command));
if ($echocmd) echo "e;CMD: {$command}\n"e;;
$response = fgets($handle, GETLENGTH);
$response = pop3_killcrlf($response);
if ($echortrn) echo "e;REPLY: {$response}\n"e;;
if (!pop3_isGoodReply($response))
{
if ($echocmd || $echortrn) echo "e;List failed\n"e;;
$errno = -3;
$errstr = "e;List command failed: {$response}"e;;
return FALSE;
}
set_time_limit(TIMEOUT);
$temp = explode("e; "e;, $response);
return array("e;msgid"e; => $tempї1], "e;size"e; => $tempї2]);
}
}
function pop3_retr($handle, $msgid, $echocmd = FALSE, $echortrn = FALSE)
{
global $errno, $errstr;
$command = "e;RETR {$msgid}\r\n"e;;
fwrite($handle, $command, strlen($command));
if ($echocmd) echo "e;CMD: {$command}\n"e;;
$response = fgets($handle, GETLENGTH);
$response = pop3_killcrlf($response);
if ($echortrn) echo "e;REPLY: {$response}\n"e;;
if (!pop3_isGoodReply($response))
{
if ($echocmd || $echortrn) echo "e;Retr failed\n"e;;
$errno = -3;
$errstr = "e;Retr command failed: {$response}"e;;
return FALSE;
}
$msg = array();
$line = fgets($handle, GETLENGTH);
while (!preg_match("e;/^\.\r\n/"e;, $line))
{
$msgї] = preg_replace("e;/^\.\./"e;, "e;."e;, $line);
$line = fgets($handle, GETLENGTH);
if (empty($line)) break;
}
set_time_limit(TIMEOUT);
return $msg;
}
function pop3_delete($handle, $msgid, $echocmd = FALSE, $echortrn = FALSE)
{
global $errno, $errstr;
$command = "e;DELE {$msgid}\r\n"e;;
fwrite($handle, $command, strlen($command));
if ($echocmd) echo "e;CMD: {$command}\n"e;;
$response = fgets($handle, GETLENGTH);
$response = pop3_killcrlf($response);
if ($echortrn) echo "e;REPLY: {$response}\n"e;;
if (!pop3_isGoodReply($response))
{
if ($echocmd || $echortrn) echo "e;Dele failed\n"e;;
$errno = -3;
$errstr = "e;Dele command failed: {$response}"e;;
return FALSE;
}
set_time_limit(TIMEOUT);
return TRUE;
}
function pop3_reset($handle, $echocmd = FALSE, $echortrn = FALSE)
{
global $errno, $errstr;
$command = "e;RSET\r\n"e;;
fwrite($handle, $command, strlen($command));
if ($echocmd) echo "e;CMD: {$command}\n"e;;
$response = fgets($handle, GETLENGTH);
$response = pop3_killcrlf($response);
if ($echortrn) echo "e;REPLY: {$response}\n"e;;
if (!pop3_isGoodReply($response))
{
if ($echocmd || $echortrn) echo "e;Rset failed\n"e;;
$errno = -3;
$errstr = "e;Rset command failed: {$response}"e;;
return FALSE;
}
set_time_limit(TIMEOUT);
return TRUE;
}
function pop3_quit($handle, $echocmd = FALSE, $echortrn = FALSE)
{
global $errno, $errstr;
$command = "e;QUIT\r\n"e;;
@fwrite($handle, $command, strlen($command));
if ($echocmd) echo "e;CMD: {$command}\n"e;;
$response = @fgets($handle, GETLENGTH);
$response = pop3_killcrlf($response);
if ($echortrn) echo "e;REPLY: {$response}\n"e;;
@fclose($handle);
return TRUE;
}
//optional functions - may not be implemented by server
function pop3_top($handle, $msgid, $numlines = '0', $echocmd = FALSE, $echortrn = FALSE)
{
global $errno, $errstr;
$command = "e;TOP {$msgid} {$numlines}\r\n"e;;
fwrite($handle, $command, strlen($command));
if ($echocmd) echo "e;CMD: {$command}\n"e;;
$response = fgets($handle, GETLENGTH);
$response = pop3_killcrlf($response);
if ($echortrn) echo "e;REPLY: {$response}\n"e;;
if (!pop3_isGoodReply($response))
{
if ($echocmd || $echortrn) echo "e;Top failed\n"e;;
$errno = -3;
$errstr = "e;Top command failed: {$response}"e;;
return FALSE;
}
$msg = array();
$line = fgets($handle, GETLENGTH);
while (!preg_match("e;/^\.\r\n/"e;, $line))
{
$msgї] = preg_replace("e;/^\.\./"e;, "e;."e;, $line);
$line = fgets($handle, GETLENGTH);
if (empty($line)) break;
}
set_time_limit(TIMEOUT);
return $msg;
}
function pop3_uidl($handle, $msgid = '', $echocmd = FALSE, $echortrn = FALSE)
{
global $errno, $errstr;
if (empty($msgid))
{
$command = "e;UIDL\r\n"e;;
fwrite($handle, $command, strlen($command));
if ($echocmd) echo "e;CMD: {$command}\n"e;;
$response = fgets($handle, GETLENGTH);
$response = pop3_killcrlf($response);
if ($echortrn) echo "e;REPLY: {$response}\n"e;;
if (!pop3_isGoodReply($response))
{
if ($echocmd || $echortrn) echo "e;Uidl failed\n"e;;
$errno = -3;
$errstr = "e;Uidl command failed: {$response}"e;;
return FALSE;
}
$messages = array();
while (preg_match("e;/^(\d+) (.*)$/"e;, fgets($handle, GETLENGTH), $lineInfo))
{
if ($echortrn) echo "e;REPLY: {$lineInfoї0]}\n"e;;
$messagesїintval($lineInfoї1])] = $lineInfoї2];
}
set_time_limit(TIMEOUT);
return $messages;
}
else
{
$command = "e;UIDL {$msgid}\r\n"e;;
fwrite($handle, $command, strlen($command));
if ($echocmd) echo "e;CMD: {$command}\n"e;;
$response = fgets($handle, GETLENGTH);
$response = pop3_killcrlf($response);
if ($echortrn) echo "e;REPLY: {$response}\n"e;;
if (!pop3_isGoodReply($response))
{
if ($echocmd || $echortrn) echo "e;Uidl failed\n"e;;
$errno = -3;
$errstr = "e;Uidl command failed: {$response}"e;;
return FALSE;
}
set_time_limit(TIMEOUT);
$temp = explode("e; "e;, $response);
return array("e;msgid"e; => $tempї1], "e;uid"e; => $tempї2]);
}
}
//helper functions
function pop3_isGoodReply($response = '')
{
if (empty($response)) return false;
if (preg_match("e;/^\+OK/"e;, $response)) return true;
return false;
}
function pop3_killcrlf($what)
{
return preg_replace("e;/\r|\n/"e;, '', $what);
}