Jump to content
MakeWebGames

Send Email Out


Recommended Posts

Hello there, I need someone to help me out. Well I need a modification to be built for me.

I need someone too make a file and send an email to everyone in my game.

 

It can only send email to people who are not in federal jail.

If someone can do this for me I would be really happy!

Or if there is one made can someone please send me the link as I am looking for one!

Good day and thanks.

UPDATE -

 

I tried too make one myself, how ever I have failed to? Everytime I send an email it does not get sent to me?

 

<?php

session_start();
require "../global_func.php";
if ($_SESSION['loggedin'] == 0)
{
   header("Location:../login.php");
   exit;
}
$userid = $_SESSION['userid'];
require "staff_header.php";
$h = new headers;
$h->startheaders();
include "staff_mysql.php";
global $c;
$is =
       mysql_query(
               "SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid",
               $c) or die(mysql_error());
$ir = mysql_fetch_array($is);
check_level();
$fm = money_formatter($ir['money']);
$cm = money_formatter($ir['crystals'], '');
$lv = date('F j, Y, g:i a', $ir['laston']);
$h->userdata($ir, $lv, $fm, $cm);
$h->staffarea();


if (!in_array($ir['user_level'], array(2)))
{
   echo 'This page cannot be accessed.<br />> <a href="index.php">Go Home</a>';
   die;

}
switch($_GET['action']) 
{
case 'sendmail' : send_mail(); break;
default: mail_index(); break;
}


function mail_index()
  {
   global $ir,$h;

echo"<h3><u>Mass Emailer</u></h3>";


  echo"<form action='staff_email.php?action=sendmail' method='post'>
       <table width=75% cellspacing=1 class='table'>
       <tr style='background: gray; '>
       <th colspan = 2>Email</th>
       </tr>



  <tr><td>Email: </td><td><textarea rows=10 cols=50 name='email'></textarea></td></tr>
  <tr><td colspan='2'><center><input type='submit' value='Send Mass Email' /></form></center></td></tr></table>";
  $h->endpage();
 }


function send_mail()
 {
  global $db,$ir,$c,$h,$userid;


  if($_POST['email'] == '')
  {
  print "You did not enter a anything.";
  $h->endpage();
  exit;
  }

  $email=mysql_query("SELECT email FROM users WHERE userid = 1");
$r=mysql_fetch_array($email);

   $news=$_POST['email'];
   $to = "{$r['email']}";
   $from = "[email protected]";
   $subject = "NationOfTheLost Newsletter";

   $message = <<<EOF
<html>
     <b><small>Hi {$r['username']},</small></b> <br / >
     <small>{$news}</small><br /><br />
     <small>That's all for this month!<br /><br />
         <b>Thanks,<br />
     Staff @ {$set['game_name']}
     </small></b>
</html>
EOF;

   $headers  = "From: $from\r\n";
   $headers .= "Content-type: text/html\r\n";

mail($to, $subject, $message, $headers);

print "Email Sent.";
$h->endpage();


}












?>
Edited by Dragon Blade
Link to comment
Share on other sites

Making an email sender to send mail is easy enough, however I would recommend using a 3rd party system like MailChimp to ensure that your mail arrives and is not in trash/spam.

Link to comment
Share on other sites

Yeah a third party would be good but he states he wants it not to send to fedded players which with a third party you have to physically manage your ML which would suck

$email=mysql_query("SELECT username, email FROM users WHERE userid = 1");
  while ($r = mysql_fetch_array($email)
  {
   $news=$_POST['email'];
   $to = $r['email'];
   $from = "[email protected]";
   $subject = "NationOfTheLost Newsletter";

   $message = <<<EOF
<html>
     <b><small>Hi {$r['username']},</small></b> <br / >
     <small>{$news}</small>
     <small>That's all for this month!
         <b>Thanks,
     Staff @ {$set['game_name']}
     </small></b>
</html>
EOF;

   $headers  = "From: $from\r\n";
   $headers .= "Content-type: text/html\r\n";

mail($to, $subject, $message, $headers);
}
print "Email Sent.";
$h->endpage();

try that out. its only a small snippet of your send email function. if that seems to work just change your where clause to filter out people fedded and check your spam too

Link to comment
Share on other sites

I send email's out to thousand's of people at a time once a month or a once every other month from my hostgator account and they all receive them. ;-) Get a good host. One email at a time should be fine.

 

Thanks Kyle, I will check that out now :)

I got my own VPS, so I think I got a good host xD

 

Yeah a third party would be good but he states he wants it not to send to fedded players which with a third party you have to physically manage your ML which would suck
$email=mysql_query("SELECT username, email FROM users WHERE userid = 1");
  while ($r = mysql_fetch_array($email)
  {
   $news=$_POST['email'];
   $to = $r['email'];
   $from = "[email protected]";
   $subject = "NationOfTheLost Newsletter";

   $message = <<<EOF
<html>
     <b><small>Hi {$r['username']},</small></b> <br / >
     <small>{$news}</small>
     <small>That's all for this month!
         <b>Thanks,
     Staff @ {$set['game_name']}
     </small></b>
</html>
EOF;

   $headers  = "From: $from\r\n";
   $headers .= "Content-type: text/html\r\n";

mail($to, $subject, $message, $headers);
}
print "Email Sent.";
$h->endpage();

try that out. its only a small snippet of your send email function. if that seems to work just change your where clause to filter out people fedded and check your spam too

Or you could use the API and add it to fedjail in which you can add and remove subscribers from the group?

Link to comment
Share on other sites

Why use a 3rd party script hosted on servers, that if sold, you could potentially lose control of?

You also have to question the legitimacy of handing all of your emails to a third party.

Yes, some big companies do it, but I imagine they have a far better TOS etc than most games online, that actually means they can since it's been agreed to.

In this case, I would suggest using a 3rd party lib, but host it yourself as then all data remains in your hands, rendering the above null.

I'd personally use SwiftMailer as I have used the lib a few times and never had issues.

Link to comment
Share on other sites

Why use a 3rd party script hosted on servers, that if sold, you could potentially lose control of?

You also have to question the legitimacy of handing all of your emails to a third party.

Yes, some big companies do it, but I imagine they have a far better TOS etc than most games online, that actually means they can since it's been agreed to.

In this case, I would suggest using a 3rd party lib, but host it yourself as then all data remains in your hands, rendering the above null.

I'd personally use SwiftMailer as I have used the lib a few times and never had issues.

MailChimp is very professional, going as far as auto trimming your lists for bounced addresses, offering a built in opt out link, and about as full analytics as you can get, including opens, clicks, average open and click rate per list, etc.

I also highly doubt they're just going to disappear with your customer data, as their longevity and client base speaks for itself.

There's nothing wrong with using a third party if they provide all the tools for you to do so without potentially messing it up by trying it yourself.

Link to comment
Share on other sites

  • 4 weeks later...

Or, instead of pretty much blanking the OP's post and suggesting everything but what he asked for, you could do this:

 

<?php
session_start();
require(DIRNAME(__DIR__) . '/global_func.php');
if(!isset($_SESSION['loggedin'])) {
header("Location: ../login.php");
exit;
}
require(__DIR__ . '/staff_header.php');
$h = new headers;
$h->startheaders();
include(__DIR__ . '/staff_mysql.php');
global $c;
$is = mysql_query("SELECT `u`.*, `us`.* FROM `users` `u` " .
				"LEFT JOIN `userstats` AS `us` ON (`u`.`userid` = `us`.`userid`) " .
				"WHERE `u`.`userid` = ".$_SESSION['userid'], $c) or die(mysql_error());
if(!mysql_num_rows($is)) {
echo "There appears to be an issue with your account";
$h->endpage();
exit;
}
$ir = mysql_fetch_array($is);
check_level();
$fm = money_formatter($ir['money']);
$cm = money_formatter($ir['crystals'], '');
$lv = date('F j, Y, g:i a', $ir['laston']);
$h->userdata($ir, $lv, $fm, $cm);
$h->staffarea();

if($ir['user_level'] != 2) {
echo 'This page cannot be accessed.> <a href="index.php">Go Home</a>';
$h->endpage();
exit;
}
if(!isset($_POST['submit'])) {
?><h3><u>Mass Emailer</u></h3>
<form action='staff_email.php' method='post'>
<table width='75%' cellspacing='1' class='table'>
	<tr style='background: gray;'>
		<th colspan='2'>Email</th>
	</tr>
	<tr>
		<th>Message</th>
		<td><textarea rows='10' cols='50' name='email'></textarea></td>
	</tr>
	<tr>
		<td colspan='2' style='text-align:center;'><input type='submit' value='Send Mass Email' /></td>
	</tr>
</table>
</form><?php
} else {
$_POST['email'] = isset($_POST['email']) && is_string($_POST['email']) ? trim($_POST['email']) : null;
if(empty($_POST['email'])) {
	echo "You didn't enter a valid message";
	$h->endpage();
	exit;
}
$email = mysql_query("SELECT `username`, `email` FROM `users` WHERE `email` != '' AND `fedjail` = 0 ORDER BY `userid` ASC") or die(mysql_error());
$subject = "NationOfTheLost Newsletter";
$message = "<strong>Hi {$r['username']},</strong><br / >
{$_POST['email']}<br />
That's all for this month!<br />
<strong>Thanks, Staff @ {$set['game_name']}</strong>";
$headers  = "From: admin@".$_SERVER['HTTP_HOST']."\r\nContent-type: text/html\r\n";
$cnt = 0;
while($row = mysql_fetch_assoc($email)) {
	++$cnt;
	mail($row['email'], $subject, $message, $headers);
}
echo "Email sent to ".$cnt." player".(($cnt == 1) ? '' : 's').".";
}
$h->endpage();

And then

[insert suggestions here]

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...