Jump to content

Pls Help


dirtbikedude

Recommended Posts

I'm having a problem with the PHP code I'm using. As of right now the code goes into the database and pulls the user's email address and puts it on the "from" subject line of an email. Although I just want to change the code so that it just automatically uses a static email address such as "noreply@mymodernmail.com" Here's the script I've tried everything imaginable to get it static but for some reason it doesn't seem to run correctly when I change it. Can anyone provide me an example of how I should change it to get it to work? I made the line bold in the post that I think needs to be changed to make it static. Thanks sooo much and merry christmas!

 

 

<?php
include('../conn/conn.php');

session_start();
include('../class/deduct_mails.php');

// load required class files 
require("class.phpmailer.php");

##if($_SESSION["pdate"]=='' && $_SESSION["ptime"]=='' && $_SESSION["msgID"]!='' && $_SESSION["send"]==0) //send mails now in edit mode
{
	$changeresponse = 1;
}

//date
$date = date('Y-M-d');
$date_array = explode("-",$date);

//message ID for read count
$messageID = $_GET['messageID'];
$readlink = "http://www.mymodernmail.com/readcount.php?messageID=$messageID";

//Unsubscribe link
$unsub = "http://www.mymodernmail.com/unsubscribe.php?groupID=$_SESSION[groupID]";



#~Getting our information form table
$request = "SELECT large_image,url,group_id
name_id 
FROM 
advertising 
WHERE 
group_id = '".$_SESSION['groupID']."'
LIMIT 1"; 
$mysql = mysql_query($request) or print mysql_error(); 
$num_mysql = mysql_num_rows($mysql) or print mysql_error(); 

#~If we have a match we will do something.
if ($num_mysql > 0) 
{ 
list($large_image,$url,$group_id) = mysql_fetch_row($mysql); 
$advertising ='<tr>
<td><a href="http://mymodernmail.com/url.php?id=.'.$url.'&url=.'.$group_id.'&mi=.'.$messageID.'><img src="http://mymodernmail.com/ad_image/$large_image" border="0" alt=""></a></td>
</tr>';
} 
else
{
$advertising = '';
}
##________________________________________________________________ 

//select the group details
$query_group_details = "select group_name,owner_id,prefix,from_line from groups where group_id='$_SESSION[groupID]'";
$result_group_details = mysql_query($query_group_details);
$data_group_details = mysql_fetch_array($result_group_details);

//select the owner email
$owner_query = "select first_name,last_name,email from user where user_id='".$data_group_details['owner_id']."'";
$owner_result = mysql_query($owner_query);
$owner = mysql_fetch_array($owner_result); 

//establish common page defaults 
//prefix option is selected

if($data_group_details['prefix']=='Group URL')   //prefix is Group URL
	$subject = $data_group_details['group_name']."@mymodernmail.com:".$_SESSION["title"];
else if($data_group_details['prefix']=='Group Name')   //prefix is Group Name
	$subject = $data_group_details['group_name'].":".$_SESSION["title"];
else
	$subject = $_SESSION["title"];

[b]$fromAddress = "$owner[email]"[/b];

//from option is selected
if($data_group_details['from_line']=='Name of the Author')   //from is Name of the Author
{
	if($_SESSION["author"]!='')
		$fromName = $_SESSION["author"]; //author entered by user
	else
		$fromName = $owner["first_name"]." ".$owner["last_name"]; //author selected from database
}
else if($data_group_details['from_line']=='Name of the Group')   //from Name of the Group
	$fromName = "$data_group_details[group_name]"; 

$replyToAddress = "$owner[email]"; 

include("../class/email_templates.php");


$group_user_details = "select user_id,type_msg from user_groups where group_id='$_SESSION[groupID]' AND blocked='no'";
$result_group_user = mysql_query($group_user_details);

	##"we do not want to send the same email twice so we will
	##do a check on our send in an array if it is in the array then we will not add
	##and continue
while($data_group_user = mysql_fetch_array($result_group_user))
	{ 
	##select users email to send mail
	$email_query = "select email,lang from user where user_id='".$data_group_user['user_id']."'";
	$email_result = mysql_query($email_query);
	$email = mysql_fetch_array($email_result); 

$tracker_open = '<img src="http://www.mymodernmail.com/groups/open.php?open='.$data_group_user['user_id'].'_'.$_SESSION['msgID'].'" width="1" height="1" alt="" />';

	##making sure that we do not double up
	##as there have been issues golabs....
	if (isset($no_double))
		{
			if (in_array($email,$no_double)) continue;
		}
	$no_double[] = $email;

##This will add a send to the users sending messages log
##________________________________________________________________
$datetime = date("Y-m-d H:i");
$request = "insert into sent_messages set 
user_id = '".$data_group_user['user_id']."',
message_id = '".$_SESSION['msgID']."',
date = '$datetime'
";
mysql_query($request) or print mysql_error(); 
##________________________________________________________________ 

	$mail = new phpmailer(); 

	$mail->PluginDir = "./"; 


	$mail->From = $fromAddress; 
	$mail->FromName = $fromName; 
	$mail->AddAddress($email['email']); 
	$mail->AddReplyTo('noreply@mymodernmail.com'); 

	$mail->WordWrap = 65; // set word wrap 
	$mail->IsHTML(true); // send as HTML 

	$mail->Subject = $subject; 


$body_html_en = "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
	<html xmlns='http://www.w3.org/1999/xhtml'>
	<head>
	<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1' />
	<title>Untitled Document</title>
	<style type='text/css'>
	<!--
	body {
		margin-left: 0px;
		margin-top: 0px;
		margin-right: 0px;
		margin-bottom: 0px;
	}
	-->
	</style>
	</head>		
	<body>
	<table width='526' border='0' align='center' cellpadding='0' cellspacing='0' background=''>
	  <tr>
		<td height='140' align='center'><a href='#'><img src='http://i192.photobucket.com/albums/z260/moderndisciples/logo.jpg' width='350' height='124' border='0' /></a></td>
	  </tr>
	  <tr>
		<td align='center'> </td>
	  </tr>
	  <tr>
		<td align='center' style='font-family:Arial, Helvetica, sans-serif; font-size:18px; color:#fdae03;'>$data_group_details[group_name]</td>
	  </tr>
	  <tr>
		<td align='center' style='font-family:Arial, Helvetica, sans-serif; font-size:13px;
	color:#000000;'>$_SESSION[title]</td>
	  </tr>
	  <tr>
		<td align='center' style='font-family:Arial, Helvetica, sans-serif; font-size:13px;
	color:#000000;'>$date_array[1] $date_array[2], $date_array[0]</td>
	  </tr>
	  <tr>
		<td align='center'> </td>
	  </tr>
	  <tr>
		<td align='center'> </td>
	  </tr>
	  <tr>
		<td align='center' style='font-family:Arial, Helvetica, sans-serif; font-size:13px;
	color:#000000;'>$_SESSION[msgbody]</td>
	  </tr>
	  <tr>
		<td align='center'> </td>
	  </tr>
          <tr>
		<td align='center'> </td>
	  </tr>
	  <tr>
		<td align='center'>If you read this Message click <a target='_blank' href='$readlink'>here</a></td>
	  </tr>	
	  <tr>
		<td align='center'> </td>
	  </tr>
	  <tr>
	  <td align='center' style='font-family:Arial, Helvetica, sans-serif; font-size:13px;
	color:#000000;'>Own a blog or already send newsletters or announcements? <strong>Use our system and we'll pay you for each subscriber you have!</strong></td>
	  </tr>
	  <tr>
		<td align='center'> </td>
	  </tr>
	  <tr>
	  <td align='center' style='font-family:Arial, Helvetica, sans-serif; font-size:13px;
	color:#000000;'><strong>Advertisers</strong> our newsletters are viewed by hundreds of thousands of users everyday. Contact us to see your ad appear on our newsletters!</td>
	  </tr>
	  <tr>
		<td align='center'> </td>
	  </tr>
	  <tr>
		<td align='center'><a href='http://www.mymodernmail.com'>http://www.mymodernmail.com</a></td>
	  </tr>
	  <tr>
	  <td align='center'> </td>
	  </tr>
	  <tr>
	  <td align='center'>If you want to Unsubscribe from this Group Please click <a target='_blank' href='$unsub'>here</a></td>
	  </tr>	  
	  <tr>
	  	<td align='center'> </td>
	  </tr>
	  <tr>
		<td align='center' style='font-family:Arial, Helvetica, sans-serif; font-size:11px;
		color:#000000;'><img src='http://i192.photobucket.com/albums/z260/moderndisciples/logo.jpg' width='350' height='124' border='0' usemap='#Map' />
		  <map name='Map' id='Map'>
			<area shape='rect' coords='8,9,71,40' href='#' />
			<area shape='rect' coords='76,8,111,39' href='#' />
			<area shape='rect' coords='118,8,200,37' href='#' />
			<area shape='rect' coords='207,7,288,36' href='#' />
			<area shape='rect' coords='298,7,362,37' href='#' />
		  </map>    </td>
	  </tr>
<tr>
<td>$advertising</td>
</tr>
	</table>
	$tracker_open 
	</body>
	</html>";

	if($data_group_user['type_msg']=='text')
	{
		if($email['lang']=='de')
		{
			$mail->Body = $body_text_de;
		}
		else
		{
			$mail->Body = $body_text_en;
		}
	}
	else
	{
		if($email['lang']=='de')
		{
			$mail->Body = $body_text_de;
		}
		else
		{
			$mail->Body = $body_html_en;
		}
	}

	if(!$mail->Send()) 
	{ 
		//do nothing
	} 
	else{ 
		//do nothing
	}
} 

//clear all session variables
session_unregister("author");
session_unregister("msgtype");
session_unregister("msgprivacy");
session_unregister("pdate");
session_unregister("ptime");
session_unregister("title");

session_unregister("editmode");

session_unregister("msgbody");
session_unregister("msgbodytext");
session_unregister("msgID");
session_unregister("send");

if($changeresponse==1)
{
	echo "<b>Message Successfully Updated in Database.</b><br><b>All mails send.</b>";
}
else
{
	echo "<b>All mails send.</b>";
}
?>

Edit: added code blocks

Link to comment
Share on other sites

Change the following lines and it should be fixed :)

 

$mail->From = "noreply@mymodernmail.com"; 
$mail->FromName = "Do Not Reply"; 

 

It's odd because I changed this and it says it worked but it doesn't send the mail correctly through the code so no email goes out. It's very weird because that was one of the changes I made before but it didn't work....any other ideas?

 

Thanks I totally appreciate it!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.