View previous topic :: View next topic |
Author |
Message |
hc2995 -
Joined: 07 Aug 2006 Posts: 644 Location: Maryland, USA
|
Posted: Sun Dec 24, 2006 2:05 am Post subject: Sending an e-mail to random recipients? |
|
|
Ok for my search engine i have a file called sendsearch.php which is designed to send an e-mail to me with the contents of the form users fill out to add a site to the engine. The way it is set up it only sends e-mails to me but i plan to one day have people help me index sites when they come in. So im asking does anyone know how i can send the e-mail to a random recipient (such as someone on the crawl team) each time the form is sent?
Here is sendsearch.php:
Code: | <?php
//sendsearch.php
//copyright © Howard Chaplinski
//To be used ONLY with "DW Search" search engine
?>
<html>
<head>
<title>Request Recieved</title>
<?php
$to = 'webmaster@searchdw.com';
$subject = 'Search Proccessor';
$headers = 'From: webmaster@searchdw.com';
$body = "
Site name: ". $_POST['site_name'] ."
Site ULR: ". $_POST['site_url'] ."
email: ". $_POST['email'] ."
Description: ". $_POST['description'] ."
Agrrement: ". $_POST['agree'] ."\r\n\r\n";
mail($to, $subject, $body, $headers);
?>
</head>
<body>
<center>
<img src="/images/crawl.gif" alt="Request Received!"><br>
<p>Thank you! Our crawl team has been notified, your site will be crawled in then next 48-72 hours.<p>
<p><b><font color="red">During this time, please make sure ALL meta tags are up to date so the crawler bot can crawl your site easier!</font><b></p>
<p>Please click <a href="http://www.searchdw.com">HERE</a> to go back</p>
</center>
</body>
</html>
|
_________________ Where have i been? School got heck-tick, had to move half way around the state, then back... and then i had to change jobs, so iv been away for a while :P
Last edited by hc2995 on Sun Dec 24, 2006 7:46 am; edited 2 times in total |
|
Back to top |
|
 |
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Sun Dec 24, 2006 5:13 am Post subject: |
|
|
Hello hc2995,
You can add an array of the team members to send the e-mail to, and use a
simple random function to know which member to send to.
Example code:
Code: | <?php
/**
* The Chosen One
* Created by: Josh (TRUSTAbyss)
*/
$team = array("user1@your-site.com", "user2@your-site.com",
"user3@your-site.com", "user4@your-site.com",
"user5@your-site.com", "user6@your-site.com");
$n = rand(0, 5);
// Lets send the random member in a new variable called
// $member and output it.
$member = $team[$n];
// Now we will output the chosen member to the browser.
echo $member;
?>
|
Note: I use 0, 3 in the rand() Function because in an Index Array, it uses
0 as the first element in an array.
Sincerely, Josh (TRUSTAbyss)
Last edited by TRUSTAbyss on Sun Dec 24, 2006 5:37 am; edited 2 times in total |
|
Back to top |
|
 |
hc2995 -
Joined: 07 Aug 2006 Posts: 644 Location: Maryland, USA
|
Posted: Sun Dec 24, 2006 5:34 am Post subject: |
|
|
Ok so would the finished script look like this:
Code: |
<?php
//sendsearch.php
//copyright © Howard Chaplinski
//To be used ONLY with "DW Search" search engine
?>
<html>
<head>
<title>Request Recieved</title>
<?php
$team = array("user1@your-site.com", "user2@your-site.com",
"user3@your-site.com", "user4@your-site.com");
$n = rand(0, 3);
// Lets send the random member in a new variable called
// $member and output it.
$member = $team[$n];
// Now we will output the chosen member to the browser.
?>
<?php
$to = $member;
$subject = 'Search Proccessor';
$headers = 'From: webmaster@searchdw.com';
$body = "
Site name: ". $_POST['site_name'] ."
Site ULR: ". $_POST['site_url'] ."
email: ". $_POST['email'] ."
Description: ". $_POST['description'] ."
Agrrement: ". $_POST['agree'] ."\r\n\r\n";
mail($to, $subject, $body, $headers);
?>
</head>
<body>
<center>
<img src="/images/crawl.gif" alt="Request Received!"><br>
<p>Thank you! Your site will be crawled by <?php echo $member; ?> If you have any questions, e-mail them<p>
<p>Your site will be crawled within the next 24-72 hours.<b><font color="red">During this time, please make sure ALL meta tags are up to date so the crawler bot can crawl your site easier!</font><b></p>
<p>Please click <a href="http://www.searchdw.com">HERE</a> to go back</p>
</center>
</body>
</html>
|
_________________ Where have i been? School got heck-tick, had to move half way around the state, then back... and then i had to change jobs, so iv been away for a while :P
Last edited by hc2995 on Sun Dec 24, 2006 5:42 am; edited 1 time in total |
|
Back to top |
|
 |
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Sun Dec 24, 2006 5:40 am Post subject: |
|
|
Yes, but you don't need any quotes when setting a variable a value of another
variable. You can use this: $to = $member
P.S. Never use single quotes in a string when a variable is included, use double
quotes instead. PHP won't render variables within single quotes. |
|
Back to top |
|
 |
hc2995 -
Joined: 07 Aug 2006 Posts: 644 Location: Maryland, USA
|
Posted: Sun Dec 24, 2006 5:42 am Post subject: |
|
|
TRUSTAbyss wrote: | Yes, but you don't need any quotes when setting a variable a value of another
variable. You can use this: $to = $member
P.S. Never use single quotes in a string when a variable is included, use double
quotes instead. PHP won't render variables within single quotes. |
Ok Ill test it out, Thanks Josh :D _________________ Where have i been? School got heck-tick, had to move half way around the state, then back... and then i had to change jobs, so iv been away for a while :P |
|
Back to top |
|
 |
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Sun Dec 24, 2006 5:43 am Post subject: |
|
|
Your Welcome. :-) |
|
Back to top |
|
 |
hc2995 -
Joined: 07 Aug 2006 Posts: 644 Location: Maryland, USA
|
Posted: Sun Dec 24, 2006 5:50 am Post subject: |
|
|
Ok here is the final code (seems working, except my ISP blocked mail for flooding :P (just for 30 mins))
Code: | <?php
// File: sendsearch.php
// Copyright: Copyright © 2006 Howard Chaplinski, ONLY FOR USE ON DW SEARCH!
// Website: http://www.searchdw.com
//
// File: sendsearch.php (random e-mail recipient portion)
// Copyright: Copyright © 2006 Josh (TRUSTAbyss), USED WITH PERMISSION!
// Website: http://www.trustabyss.com
?>
<html>
<head>
<title>Request Recieved</title>
<?php
$team = array("webmaster@directwebmasters.com", "webmaster@searchdw.com");
$n = rand(0, 1);
// Lets send the random member in a new variable called
// $member and output it.
$member = $team[$n];
// Now we will output the chosen member to the browser.
?>
<?php
$to = $member;
$subject = 'Search Proccessor';
$headers = 'From: webmaster@searchdw.com';
$body = "
Site name: ". $_POST['site_name'] ."
Site ULR: ". $_POST['site_url'] ."
email: ". $_POST['email'] ."
Description: ". $_POST['description'] ."
Agrrement: ". $_POST['agree'] ."\r\n\r\n";
mail($to, $subject, $body, $headers);
?>
</head>
<body>
<center>
<img src="/images/crawl.gif" alt="Request Received!"><br>
<p>Thank you! Your site will be crawled by <b><?php echo $member; ?><b> If you have any questions, e-mail them<p>
<p>Your site will be crawled within the next 24-72 hours.<b><font color="red">During this time, please make sure ALL meta tags are up to date so the crawler bot can crawl your site easier!</font><b></p>
<p>Please click <a href="http://www.searchdw.com">HERE</a> to go back</p>
</center>
</body>
</html>
|
Thanks again Josh,
Hc2995 _________________ Where have i been? School got heck-tick, had to move half way around the state, then back... and then i had to change jobs, so iv been away for a while :P |
|
Back to top |
|
 |
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Sun Dec 24, 2006 6:36 am Post subject: |
|
|
Looks good to me. You can remove those unwanted comments if you want.
Thanks for the credits by the way. |
|
Back to top |
|
 |
hc2995 -
Joined: 07 Aug 2006 Posts: 644 Location: Maryland, USA
|
Posted: Sun Dec 24, 2006 7:48 am Post subject: |
|
|
TRUSTAbyss wrote: | Looks good to me. You can remove those unwanted comments if you want.
Thanks for the credits by the way. |
Thats no problem, it wouldnt be right of me to take credit for your work _________________ Where have i been? School got heck-tick, had to move half way around the state, then back... and then i had to change jobs, so iv been away for a while :P |
|
Back to top |
|
 |
|
|
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
|
|