Jump to content

[SOLVED] help with a subscription form


Rachel W

Recommended Posts

Hello, I really hope someone can help me.

I have been trying to set up a mailing list manager and came across phpmynewsletter.  I have it set up on my web server but now have to figure out how to place a form so that people can sign-up for the list.

 

The program gives me a script for a form, but I am having a hard time knowing how to change the things it asks me to and also where it would go in a web page.  Also, I am not sure if this script is a form in itself or if a form would have to be designed as well.

 

They actually give me two scripts, one called form and the other subscription.  I will attach both.

 

In terms of the information needed to complete the information the website that it will be going into is a subdomain, lets call it investors.white.com and the file pmnl is in a folder investors_html which is in the public_html folder.  The sub-domain points to investors_html.

 

Any help would be amazing.  I was trying to set up nomodomo but hit a wall so tried this program which seems better anyway, but I am setting up the website for a friend and I really need to get it finished for him.

 

Thank you.

 

Rachel

 

[attachment deleted by admin]

Link to comment
Share on other sites

Sure, I did not know to do that.  Sorry.

<?php
// you can include this form in any page of
// your website as follow:
//
// in this file, provide correct values for:
// $path_to_pmnl
// $list_id newsletter id
// then in your page (need to be a php page) 
// add this line :
// include("path/to/this/page/form.php");
// NOTA: your page need to use UTF8 encoding
// put 
// <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
// in your html header




//path to phpMyNewsletter base directory
$path_to_pmnl="./";

// newsletter id, leave this empty if you want to list available
// newsletter.

//$list_id = 1;
$list_id = "";

//display archive link (true or false) ?
$display_archive=true;







////////////////////// DO NOT MODIFY /////////////////////

if(file_exists("./".$path_to_pmnl."include/config.php")){
  include("./".$path_to_pmnl."include/config.php");
  include("./".$path_to_pmnl."include/db/db_".$db_type.".inc.php");
}
include("./".$path_to_pmnl."include/lib/libconfig.php");
include("./".$path_to_pmnl."include/interface.php");
include("./".$path_to_pmnl."include/lib/libnewsletter.php");
include("./".$path_to_pmnl."admin/include/function.php");


if(file_exists("./".$path_to_pmnl."include/config.php")){
   print newsletter_list($list_id, true, $display_archive);
  } else {
  include "./".$path_to_pmnl."include/lang/english.php";
  echo error_msg(translate("NEWSLETTER_NOT_YET"));
}

?>

 

Now the subscription script - it is very long, sorry, one of the reasons why I did not paste it originally.

 

<?
include("include/config.php");
include("include/lib/libconfig.php");
include("include/db/db_".$db_type.".inc.php");
include("include/interface.php");
include("include/lib/libnewsletter.php");
include("admin/include/function.php");
include("include/lib/class.phpmailer.php");



//dirty hack
if (!function_exists('iconv') && function_exists('libiconv')) {
       function iconv($input_encoding, $output_encoding, $string) {
          return libiconv($input_encoding, $output_encoding, $string);
       }
}

if(!function_exists('iconv') && !function_exists('libiconv')) {
     include_once("./include/lib/ConvertCharset.class.php");

       function iconv($input_encoding, $output_encoding, $string) {
          $converter = new ConvertCharset();
          return $converter->Convert($string, $input_encoding, $output_encoding);
       }
}

$conf = new config();
$conf->getConfig($hostname,$login ,$pass,$database, $table_global_config);
include("include/lang/".$conf->language.".php");


$list_id = (!empty($_POST['list_id']) ? $_POST['list_id'] : "");
$list_id = (empty($list_id) && !empty($_GET['list_id']) ? $_GET['list_id'] : $list_id);

$email_addr = (!empty($_POST['email_addr']) ? $_POST['email_addr'] : "");
$email_addr = (empty($email_addr) && !empty( $_GET['email_addr']) ? $_GET['email_addr'] : $email_addr);

$op = (!empty($_POST['op']) ? $_POST['op'] : "");
$op = (empty($op) && !empty( $_GET['op']) ? $_GET['op'] : $op);

$hash = (!empty($_POST['hash']) ? $_POST['hash'] : "");
$hash = (empty($hash) && !empty( $_GET['hash']) ? $_GET['hash'] : $hash);


if($op == "leave" && !$conf->unsub_validation){
  $op = "leave_direct";
} else if($op == "leave_direct" && $conf->unsub_validation){
  $op = "leave";
} else if($op == "join" && !$conf->sub_validation){
  $op = "join_direct";
} else if($op == "join_direct" && $conf->sub_validation){
  $op = "join";
}


$popup = (!empty($_POST['popup']) ? $_POST['popup'] : "" );

if(isset($list_id) && !empty($list_id) && isValidNewsletter($conf->db_host, $conf->db_login, $conf->db_pass, $conf->db_name, $conf->table_listsconfig, $list_id) && isset($email_addr)){


  if( !validEmailAddress($email_addr) ) {
    html_header(translate("NEWSLETTER_TITLE"));
    echo "<div class='subsection2$popup'>";
    echo "<div class='subtitle'>".translate("SUBSCRIPTION_TITLE")."</div>";
    echo "<div class='subcontent'>";
    echo "<div align='center' class='error$popup'>".translate("EMAIL_ADDRESS_NOT_VALID")."</div>";
    if(empty($popup)){	echo "<div align='center'><img src='img/puce.gif'> <a href='#' onclick='history.back()'>".translate("BACK")."</a></div>";}
    echo "</div></div>";
    html_footer();
    exit();
  }
  
  switch($op)
    {
    case "join":
      html_header(translate("NEWSLETTER_TITLE"));

      echo "<div class='subsection2$popup'>";
      echo "<div class='subtitle'>".translate("SUBSCRIPTION_TITLE")."</div>";
      echo "<div class='subcontent'>";


      if(!$conf->mod_sub){

$add = addSubscriberTemp( $conf->db_host, $conf->db_login, $conf->db_pass, $conf->db_name, $conf->table_email, $conf->table_temp , $list_id, $email_addr);
$news = new Newsletter();
$news->getConfig($hostname,$login ,$pass,$database, $list_id,$conf->table_listsconfig);

if(strlen($add) > 3){

  $body = $news->subscription_body;
  $body.= "\n\n".translate("SUBSCRIPTION_MAIL_BODY").":\n";
  $body.= $conf->base_url.$conf->path."subscription.php?op=confirm_join&email_addr=".urlencode($email_addr)."&hash=$add&list_id=$list_id";

  $subj = (strtoupper($conf->charset) == "UTF-8" ? $news->subscription_subject : iconv( "UTF-8", $conf->charset , $news->subscription_subject));
  $body = (strtoupper($conf->charset) == "UTF-8" ? $body : iconv( "UTF-8", $conf->charset , $body));

  $mail=sendEmail($conf->sending_method,$email_addr,$news->from, $news->from_name,$subj,$body, 
		  $conf->smtp_auth, $conf->smtp_host, $conf->smtp_login, $conf->smtp_pass, $conf->charset);

  echo "<div align='center' class='success$popup'>".translate("SUBSCRIPTION_SEND_CONFIRM_MESSAGE")."</div>";
}
else if($add==0)
  echo "<div align='center' class='error$popup'>".translate("SUBSCRIPTION_ALREADY_SUBSCRIBER")."</div>";
else
  echo "<div align='center' class='error$popup'>".translate("ERROR_SQL2", DbError())."</div>";

if(empty($popup)){	echo "<div align='center'><img src='img/puce.gif'> <a href='#' onclick='history.back()'>".translate("BACK")."</a></div>";}
      }
      
      else {

$add = addSubscriberMod($conf->db_host, $conf->db_login, $conf->db_pass, $conf->db_name, $conf->table_email, $conf->table_sub , $list_id, $email_addr);
if($add)
  echo "<div align='center' class='success$popup'>".translate("Subscription requested recorded, waiting for moderation")."</div>";

else if($add==0)
  echo "<div align='center' class='error$popup'>".translate("You are already a subscriber")."</div>";
else
  echo "<div align='center' class='error$popup'>".translate("Error while SQL query")."</div>";
echo "<div align='center'><img src='img/puce.gif'> <a href='index.php'>".translate("Back")."</a></div>";
      }


echo "</div></div>";




      html_footer();
      break;


    case "leave":
      html_header(translate("NEWSLETTER_TITLE"));

      $news = new Newsletter();
      $news->getConfig($hostname,$login ,$pass,$database, $list_id,$conf->table_listsconfig);

      $hash = isValidSubscriber($conf->db_host,$conf->db_login ,$conf->db_pass,$conf->db_name, $conf->table_email, $list_id, $email_addr);


echo "<div class='subsection2$popup'>";
echo "<div class='subtitle'>".translate("UNSUBSCRIPTION_TITLE")."</div>";
echo "<div class='subcontent'>";

      if($hash){
  $body = $news->quit_body;
  $body.= "\n\n".translate("UNSUBSCRIPTION_MAIL_BODY")." :\n";
  $body.= $conf->base_url.$conf->path."subscription.php?op=confirm_leave&email_addr=".urlencode($email_addr)."&hash=$hash&list_id=$list_id";

  $subj = (strtoupper($conf->charset) == "UTF-8" ? $news->quit_subject : iconv( "UTF-8", $conf->charset , $news->quit_subject));
  $body = (strtoupper($conf->charset) == "UTF-8" ? $body : iconv( "UTF-8", $conf->charset , $body));

  if(sendEmail($conf->sending_method,$email_addr,$news->from, $news->from_name, $subj, $body
	       , $conf->smtp_auth, $conf->smtp_host, $conf->smtp_login, $conf->smtp_pass, $conf->charset))
    echo "<div align='center' class='success$popup'>".translate("SUBSCRIPTION_SEND_CONFIRM_MESSAGE")."</div>";
  else
    echo "<div align='center' class='error$popup'>".translate("ERROR_SENDING_CONFIRM_MAIL")."</div>";
}
      else
echo "<div align='center' class='error$popup'>".translate("You are not a subscriber of this newsletter")."</div>";

      if(empty($popup)){          echo "<div align='center'><img src='img/puce.gif'> <a href='index.php'>".translate("BACK")."</a></div>";}

      echo "</div></div>";
      
      echo "</td></tr>";
      table_footer();
      page_footer();
      html_footer();
      break;
      
      
      
    case "confirm_join":
      html_header(translate("NEWSLETTER_TITLE"));
      
      $add= addSubscriber( $conf->db_host, $conf->db_login, $conf->db_pass, $conf->db_name, $conf->table_email, $conf->table_temp , $list_id, $email_addr,$hash);
      echo "<div class='subsection2$popup'>";
      echo "<div class='subtitle'>".translate("SUBSCRIPTION_CONFIRMATION")."</div>";
      echo "<div class='subcontent'>";
      if($add==-1){
echo "<div align='center' class='error$popup'>".translate("SUBSCRIPTION_UNKNOWN_EMAIL_ADDRESS")."! </div>";
      } elseif($add) {
$news = new Newsletter();
$news->getConfig($hostname,$login ,$pass,$database, $list_id,$conf->table_listsconfig);

$body = $news->welcome_body;
$body.= "\n\n".translate("SUBSCRIPTION_UNSUBSCRIBE_LINK").":\n";
$body.= $conf->base_url.$conf->path."subscription.php?op=confirm_leave&email_addr=".urlencode($email_addr)."&hash=$hash&list_id=$list_id";

$subj = (strtoupper($conf->charset) == "UTF-8" ? $news->welcome_subject : iconv( "UTF-8", $conf->charset , $news->welcome_subject));
$body = (strtoupper($conf->charset) == "UTF-8" ? $body : iconv( "UTF-8", $conf->charset , $body));

$mail = sendEmail($conf->sending_method,$email_addr,$news->from, $news->from_name,$subj, $body, 
		  $conf->smtp_auth, $conf->smtp_host, $conf->smtp_login, $conf->smtp_pass, $conf->charset);

echo "<div align='center' class='success$popup'>".translate("SUBSCRIPTION_FINISHED")."</div>";
      }
      else {
echo "<div align='center' class='error$popup'>".translate("ERROR_UNKNOWN")."</div>";
      }
      
      
      echo "</div></div>";
      html_footer();
      break;
          



    case "confirm_leave":
      html_header(translate("NEWSLETTER_TITLE"));
      $rm=removeSubscriber($conf->db_host, $conf->db_login, $conf->db_pass, $conf->db_name, $conf->table_email,  $list_id, $email_addr,$hash);
echo "<div class='subsection2$popup'>";
echo "<div class='subtitle'>".translate("UNSUBSCRIPTION_CONFIRMATION")."</div>";
echo "<div class='subcontent'>";

      if($rm==1)
echo "<div align='center' class='success$popup'>".translate("UNSUBSCRIPTION_FINISHED").".</div>";
      else if($rm==-1)
echo "<div align='center' class='error$popup'>".translate("UNSUBSCRIPTION_UNKNOWN_EMAIL_ADDRESS")."</div>";
      else
echo "<div align='center' class='error$popup'>".translate("ERROR_UNKNOWN")."</div>";

echo "</div></div>";
      html_footer();


      break;



    case "join_direct":

      if(!$conf->sub_validation){
      html_header(translate("NEWSLETTER_TITLE"));
echo "<div class='subsection2$popup'>";
echo "<div class='subtitle'>".translate("SUBSCRIPTION_TITLE")."</div>";
echo "<div class='subcontent'>";

      $add = addSubscriberDirect($conf->db_host, $conf->db_login, $conf->db_pass, $conf->db_name, $conf->table_email,  $list_id, $email_addr);
      /* $add not -1 nor -2 
TODO:need to be rewritten
      */
      if(strlen($add) > 2){
  $news = new Newsletter();
  $news->getConfig($hostname,$login ,$pass,$database, $list_id,$conf->table_listsconfig);

  $body = $news->welcome_body;
  $body.= "\n\n".translate("UNSUBSCRIPTION_MAIL_BODY").":\n";
  $body.= $conf->base_url.$conf->path."subscription.php?op=confirm_leave&email_addr=".urlencode($email_addr)."&hash=$add&list_id=$list_id";

  $subj = (strtoupper($conf->charset) == "UTF-8" ? $news->welcome_subject : iconv( "UTF-8", $conf->charset , $news->welcome_subject));
  $body = (strtoupper($conf->charset) == "UTF-8" ? $body : iconv( "UTF-8", $conf->charset , $body));

  $mail = sendEmail($conf->sending_method,$email_addr,$news->from, $news->from_name,$subj,$body, 
		    $conf->smtp_auth, $conf->smtp_host, $conf->smtp_login, $conf->smtp_pass, $conf->charset );
  
  echo "<div align='center' class='success$popup'>".translate("SUBSCRIPTION_FINISHED")."</div>";
}
      else if($add==-1){
echo "<div align='center' class='error$popup'>".translate("SUBSCRIPTION_ALREADY_SUBSCRIBER")."</div>";
} else {
echo "<div align='center' class='error$popup'>".translate("ERROR_UNKNOWN")."</div>";
}
      if(empty($popup)){      echo "<div align='center'><img src='img/puce.gif'> <a href='#' onclick='history.back()'>".translate("BACK")."</a></div>";}
echo "</div></div>";
      html_footer();

      }
      else
header("Location:index.php");

      break;


    case "leave_direct":
      if(!$conf->unsub_validation){

html_header(translate("NEWSLETTER_TITLE"));
$rm=removeSubscriberDirect($conf->db_host, $conf->db_login, $conf->db_pass, $conf->db_name, $conf->table_email, $list_id, $email_addr);

echo "<div class='subsection2$popup'>";
echo "<div class='subtitle'>".translate("UNSUBSCRIPTION_TITLE")."</div>";
echo "<div class='subcontent'>";

if($rm==1)
  echo "<div align='center' class='success$popup'>".translate("UNSUBSCRIPTION_FINISHED").".</div>";
else if($rm==-1)
  echo "<div align='center' class='error$popup'>".translate("UNSUBSCRIPTION_UNKNOWN_EMAIL_ADDRESS")."</div>";
else
  echo "<div align='center' class='error$popup'>".translate("ERROR_UNKNOWN")."</div>";

if(empty($popup)){	echo "<div align='center'><img src='img/puce.gif'> <a href='index.php'>".translate("BACK")."</a></div>";}
echo "</div></div>";
html_footer();
      }

      else
header("Location:index.php");
      break;






    default:
      header("Location:index.php");
      break;

    }
}
else
header("Location:index.php");



?>

 

Link to comment
Share on other sites

I don't know.  That is why I need the help.  Basically I need a sign-up form for the website that will add the subscribers to the phpmynewsletter and they don't really explain how.  They just tell you how to upload and install the program, which I have.  I can access it and see current subscribers.  I can manually add people but the whole idea is that people can sign-up using a form, which I assume is the form.php but I don't know how to format it in the way they ask.

 

maybe if someone could tell me how to add the info in the form.php I can try putting that into a web page and see how it looks, but I need to know what path to type in there and where I would put the meta tag and also where I would put the path that they mention in the file.

 

Thanks so much.

Link to comment
Share on other sites

Actually, I did not think of looking at the uploaded files from the browser (I just looked at the ones I had on my hard drive) and so when I opened that link it created a form that you can put in an email and then subscribe or unsubscribe, which is great.  However, I now have another issue.  When I typed my email, which I had already added to the mailing list and tried to subscribe, it told me I was already subscribed, which is great as it means that the form is linking to the database.  However, the other issue is that when I unsubscribed, it told me that I had received an email to click on, which is fine, but then when I clicked in the email to confirm this, it opened a page that it could not find. 

 

If someone could help me with the lines that need to be adjusted in the form.php then may be this would help make everything work okay.

 

Thanks so much.

 

Rachel

 

Link to comment
Share on other sites

There is none that I can see and there is no tools file either!

 

I have tried the subscription.php and it seems to work fine right now, so unless I want people to confirm their subscription via email it should work fine.

 

I do have one more question though. The subscription.php that I posted above is how it appears if I look at the file in a notepad format, however if I open the page and then right click I get a different page source as follows:

 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
 <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 	<link rel="stylesheet" href="phpmynewsletter.css" type="text/css" />
 	<title>phpMyNewsletter</title>
 </head>
<body>
 <script language="JavaScript1.2" type="text/javascript">
   function submitform() {
   	if  (document.sub_form.email_addr.value=='')
 			alert("This email address is not valid");
	else {
 				if ( ((document.sub_form.email_addr.value.indexOf('@',1))==-1)||(document.sub_form.email_addr.value.indexOf('.',1))==-1 )
 					alert("This email address is not valid");

 				else {
                                       window.open("", "formPopup", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,height=200,width=500,toolbar=no", true); 
                                	document.sub_form.target='formPopup';
 					document.sub_form.submit();
                                     }
 		}
 }	
 </script><br />

<div class='content'><form action="subscription.php" method="post" name="sub_form" target="formPopup" onsubmit="submitform();false;">
		<input type="text" size="15" name="email_addr" value="Email address" onfocus="if (this.value=='Email address') this.value=''" />
 <input type="button" name="sub" value=" O K " onclick="submitform()" /><br />

   <input type="radio" class='radio' name="op" value="join_direct" checked="checked" /> Subscribe
	<input type="radio" class='radio' name="op" value="leave_direct" /> Unsubscribe<input type='hidden' name='list_id' value='1'><input type='hidden' name='popup' value="_popup">	</form>
<div align="center"><a href="archives.php">Browse archives</a></div></div><br /><div align='center'><a href='http://gregory.kokanosky.free.fr/phpmynewsletter/' target='_blank'><img src='img/button_pmnl.png' alt='logo pmnl' title='powered by phpMyNewsletter' border='0' /></a></div></body></html>

 

This clearly shows an item that I would prefer not to have on the page which is the line

<div align="center"><a href="archives.php">Browse archives</a></div> (near the bottom)

 

The reason I don't want to see this is because it actually allows people to look at all the old newsletters which I don't necessarily want. If I open the file to change it it shows the first code, not the one above, and the old one doesn't have such a line.

 

Sorry that I am going off on a tangent but if this can be solved as well then that would be great. 

 

I have also found that even if I don't have to have a subscription confirmed an email is still sent out with an unsubscribe link as mentioned earlier in it that links to an invalid page and does not unsubscribe the user.  I cannot find anywhere that I can change this in the admin area.

 

Sorry that I have added another issue.

 

Thanks

 

Rachel

Link to comment
Share on other sites

Oh maybe that's why! Because there is no newslettersubscription.php, you get a page not found.

 

I can fix that for you. In the email, change newslettersubscription.php to subscription.php. You'll have to find the file that has that in the email.  :)

 

After that, everything should work.

Link to comment
Share on other sites

I cannot find where to find it.  I looked in all the files for the newslettersubscription.php to change it and even went into the database itself, but could not find it. 

Does anyone have any ideas from looking at the codes where I should look?

 

Thanks

 

Rachel

 

Link to comment
Share on other sites

I did not look for the file as I know it does not exist but I looked in every file I could think of that could possibly do that and then within it I looked for the line that had the words newslettersubscription.php in it so that I could change the line to subscription.php but so far I have not been able to find anything that mentions it.

Link to comment
Share on other sites

here is the code for the class.phpmailer.php

 

<?php
////////////////////////////////////////////////////
// PHPMailer - PHP email class
//
// Class for sending email using either
// sendmail, PHP mail(), or SMTP.  Methods are
// based upon the standard AspEmail(tm) classes.
//
// Copyright (C) 2001 - 2003  Brent R. Matzelle
//
// License: LGPL, see LICENSE
////////////////////////////////////////////////////

/**
* PHPMailer - PHP email transport class
* @package PHPMailer
* @author Brent R. Matzelle
* @copyright 2001 - 2003 Brent R. Matzelle
*
* Support for online.net by G. Kokanosky (c) 2005
* 
*/
class PHPMailer
{
    /////////////////////////////////////////////////
    // PUBLIC VARIABLES
    /////////////////////////////////////////////////

    /**
     * Email priority (1 = High, 3 = Normal, 5 = low).
     * @var int
     */
    var $Priority          = 3;

    /**
     * Sets the CharSet of the message.
     * @var string
     */
    var $CharSet           = "iso-8859-1";

    /**
     * Sets the Content-type of the message.
     * @var string
     */
    var $ContentType        = "text/plain";

    /**
     * Sets the Encoding of the message. Options for this are "8bit",
     * "7bit", "binary", "base64", and "quoted-printable".
     * @var string
     */
    var $Encoding          = "8bit";

    /**
     * Holds the most recent mailer error message.
     * @var string
     */
    var $ErrorInfo         = "";

    /**
     * Sets the From email address for the message.
     * @var string
     */
    var $From               = "root@localhost";

    /**
     * Sets the From name of the message.
     * @var string
     */
    var $FromName           = "Root User";

    /**
     * Sets the Sender email (Return-Path) of the message.  If not empty,
     * will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.
     * @var string
     */
    var $Sender            = "";

    /**
     * Sets the Subject of the message.
     * @var string
     */
    var $Subject           = "";

    /**
     * Sets the Body of the message.  This can be either an HTML or text body.
     * If HTML then run IsHTML(true).
     * @var string
     */
    var $Body               = "";

    /**
     * Sets the text-only body of the message.  This automatically sets the
     * email to multipart/alternative.  This body can be read by mail
     * clients that do not have HTML email capability such as mutt. Clients
     * that can read HTML will view the normal Body.
     * @var string
     */
    var $AltBody           = "";

    /**
     * Sets word wrapping on the body of the message to a given number of 
     * characters.
     * @var int
     */
    var $WordWrap          = 0;

    /**
     * Method to send mail: ("mail", "sendmail", or "smtp", or even "online").
     * @var string
     */
    var $Mailer            = "mail";

    /**
     * Sets the path of the sendmail program.
     * @var string
     */
    var $Sendmail          = "/usr/sbin/sendmail";
    
    /**
     * Path to PHPMailer plugins.  This is now only useful if the SMTP class 
     * is in a different directory than the PHP include path.  
     * @var string
     */
    var $PluginDir         = "";

    /**
     *  Holds PHPMailer version.
     *  @var string
     */
    var $Version           = "1.72";

    /**
     * Sets the email address that a reading confirmation will be sent.
     * @var string
     */
    var $ConfirmReadingTo  = "";

    /**
     *  Sets the hostname to use in Message-Id and Received headers
     *  and as default HELO string. If empty, the value returned
     *  by SERVER_NAME is used or 'localhost.localdomain'.
     *  @var string
     */
    var $Hostname          = "";

    /////////////////////////////////////////////////
    // SMTP VARIABLES
    /////////////////////////////////////////////////

    /**
     *  Sets the SMTP hosts.  All hosts must be separated by a
     *  semicolon.  You can also specify a different port
     *  for each host by using this format: [hostname:port]
     *  (e.g. "smtp1.example.com:25;smtp2.example.com").
     *  Hosts will be tried in order.
     *  @var string
     */
    var $Host        = "localhost";

    /**
     *  Sets the default SMTP server port.
     *  @var int
     */
    var $Port        = 25;

    /**
     *  Sets the SMTP HELO of the message (Default is $Hostname).
     *  @var string
     */
    var $Helo        = "";

    /**
     *  Sets SMTP authentication. Utilizes the Username and Password variables.
     *  @var bool
     */
    var $SMTPAuth     = false;

    /**
     *  Sets SMTP username.
     *  @var string
     */
    var $Username     = "";

    /**
     *  Sets SMTP password.
     *  @var string
     */
    var $Password     = "";

    /**
     *  Sets the SMTP server timeout in seconds. This function will not 
     *  work with the win32 version.
     *  @var int
     */
    var $Timeout      = 10;

    /**
     *  Sets SMTP class debugging on or off.
     *  @var bool
     */
    var $SMTPDebug    = false;

    /**
     * Prevents the SMTP connection from being closed after each mail 
     * sending.  If this is set to true then to close the connection 
     * requires an explicit call to SmtpClose(). 
     * @var bool
     */
    var $SMTPKeepAlive = false;

    /**#@+
     * @access private
     */
    var $smtp            = NULL;
    var $to              = array();
    var $cc              = array();
    var $bcc             = array();
    var $ReplyTo         = array();
    var $attachment      = array();
    var $CustomHeader    = array();
    var $message_type    = "";
    var $boundary        = array();
    var $language        = array();
    var $error_count     = 0;
    var $LE              = "\n";
    /**#@-*/
    
    // VARIABLE METHODS

    /**
     * Sets message type to HTML.  
     * @param bool $bool
     * @return void
     */
    function IsHTML($bool) {
        if($bool == true)
            $this->ContentType = "text/html";
        else
            $this->ContentType = "text/plain";
    }

    /**
     * Sets Mailer to send message using SMTP.
     * @return void
     */
    function IsSMTP() {
        $this->Mailer = "smtp";
    }

    /**
     * Sets Mailer to send message using PHP mail() function.
     * @return void
     */
    function IsMail() {
        $this->Mailer = "mail";
    }

    /**
     * Sets Mailer to send message using PHP email() online.net 
     * specific function.
     * Returns void.
     * @access public
     * @return void
     */
    function IsOnlineEmail() {
        $this->Mailer = "online";
    }

    /**
     * Sets Mailer to send message using the $Sendmail program.
     * @return void
     */
    function IsSendmail() {
        $this->Mailer = "sendmail";
    }

    /**
     * Sets Mailer to send message using the qmail MTA. 
     * @return void
     */
    function IsQmail() {
        $this->Sendmail = "/var/qmail/bin/sendmail";
        $this->Mailer = "sendmail";
    }


    /////////////////////////////////////////////////
    // RECIPIENT METHODS
    /////////////////////////////////////////////////

    /**
     * Adds a "To" address.  
     * @param string $address
     * @param string $name
     * @return void
     */
    function AddAddress($address, $name = "") {
        $cur = count($this->to);
        $this->to[$cur][0] = trim($address);
        $this->to[$cur][1] = $name;
    }

    /**
     * Adds a "Cc" address. Note: this function works
     * with the SMTP mailer on win32, not with the "mail"
     * mailer.  
     * @param string $address
     * @param string $name
     * @return void
    */
    function AddCC($address, $name = "") {
        $cur = count($this->cc);
        $this->cc[$cur][0] = trim($address);
        $this->cc[$cur][1] = $name;
    }

    /**
     * Adds a "Bcc" address. Note: this function works
     * with the SMTP mailer on win32, not with the "mail"
     * mailer.  
     * @param string $address
     * @param string $name
     * @return void
     */
    function AddBCC($address, $name = "") {
        $cur = count($this->bcc);
        $this->bcc[$cur][0] = trim($address);
        $this->bcc[$cur][1] = $name;
    }

    /**
     * Adds a "Reply-to" address.  
     * @param string $address
     * @param string $name
     * @return void
     */
    function AddReplyTo($address, $name = "") {
        $cur = count($this->ReplyTo);
        $this->ReplyTo[$cur][0] = trim($address);
        $this->ReplyTo[$cur][1] = $name;
    }

    // MAIL SENDING METHODS

    /**
     * Creates message and assigns Mailer. If the message is
     * not sent successfully then it returns false.  Use the ErrorInfo
     * variable to view description of the error.  
     * @return bool
     */
    function Send() {
        $header = "";
        $body = "";
        $result = true;

        if((count($this->to) + count($this->cc) + count($this->bcc)) < 1)
        {
            $this->SetError($this->Lang("provide_address"));
            return false;
        }

        // Set whether the message is multipart/alternative
        if(!empty($this->AltBody))
            $this->ContentType = "multipart/alternative";

        $this->error_count = 0; // reset errors
        $this->SetMessageType();
        $header .= $this->CreateHeader();
        $body = $this->CreateBody();

        if($body == "") { return false; }

        // Choose the mailer
        switch($this->Mailer)
        {
            case "sendmail":
                $result = $this->SendmailSend($header, $body);
                break;
            case "mail":
                $result = $this->MailSend($header, $body);
                break;
            case "smtp":
                $result = $this->SmtpSend($header, $body);
                break;
    case "online":
	$result = $this->EmailSend($header, $body);
	break;
            default:
            $this->SetError($this->Mailer . $this->Lang("mailer_not_supported"));
                $result = false;
                break;
        }

        return $result;
    }
    
    /**
     * Sends mail using the $Sendmail program.  
     * @access private
     * @return bool
     */
    function SendmailSend($header, $body) {
        if ($this->Sender != "")
            $sendmail = sprintf("%s -oi -f %s -t", $this->Sendmail, $this->Sender);
        else
            $sendmail = sprintf("%s -oi -t", $this->Sendmail);

        if(!@$mail = popen($sendmail, "w"))
        {
            $this->SetError($this->Lang("execute") . $this->Sendmail);
            return false;
        }

        fputs($mail, $header);
        fputs($mail, $body);
        
        $result = pclose($mail) >> 8 & 0xFF;
        if($result != 0)
        {
            $this->SetError($this->Lang("execute") . $this->Sendmail);
            return false;
        }

        return true;
    }

    /**
     * Sends mail using the PHP mail() function.  
     * @access private
     * @return bool
     */
    function MailSend($header, $body) {
        $to = "";
        for($i = 0; $i < count($this->to); $i++)
        {
            if($i != 0) { $to .= ", "; }
            $to .= $this->to[$i][0];
        }

        if ($this->Sender != "" && strlen(ini_get("safe_mode"))< 1)
        {
            $old_from = ini_get("sendmail_from");
            ini_set("sendmail_from", $this->Sender);
            $params = sprintf("-oi -f %s", $this->Sender);
            $rt = @mail($to, $this->EncodeHeader($this->Subject), $body, 
                        $header, $params);
        }
        else
            $rt = @mail($to, $this->EncodeHeader($this->Subject), $body, $header);

        if (isset($old_from))
            ini_set("sendmail_from", $old_from);

        if(!$rt)
        {
            $this->SetError($this->Lang("instantiate"));
            return false;
        }

        return true;
    }

    /**
     * Sends mail using the online.net specific email() function.  
     * @access private
     * @return bool
     */
    function EmailSend($header, $body) {
        $to = "";
        for($i = 0; $i < count($this->to); $i++)
        {
            if($i != 0) { $to .= ", "; }
            $to .= $this->to[$i][0];
        }

list($from, $foo) = split("@", $this->From);
$replyTo = $from;

//Online.net seems to want only this part of mail header ...
        $header  = "Content-Type:".$this->ContentType.";charset=".$this->CharSet."\n";
        $header .= "Content-Transfer-Encoding: ".$this->Encoding."\n";
        $header .= "Return-path: ".$this->From."\n";

        if ($this->Sender != "" && strlen(ini_get("safe_mode"))< 1)
        {
            $old_from = ini_get("sendmail_from");
            ini_set("sendmail_from", $this->Sender);
            $params = sprintf("-oi -f %s", $this->Sender);
            $rt = @email($from, $to, $this->EncodeHeader($this->Subject), $body, $replyTo,
                        $header, $params);
        }
        else
            $rt = @email($from, $to, $this->EncodeHeader($this->Subject), $body, $replyTo, $header);

        if (isset($old_from))
            ini_set("sendmail_from", $old_from);

        if(!$rt)
        {
            $this->SetError($this->Lang("instantiate"));
            return false;
        }

        return true;
    }


    /**
     * Sends mail via SMTP using PhpSMTP (Author:
     * Chris Ryan).  Returns bool.  Returns false if there is a
     * bad MAIL FROM, RCPT, or DATA input.
     * @access private
     * @return bool
     */
    function SmtpSend($header, $body) {
        include_once($this->PluginDir . "class.smtp.php");
        $error = "";
        $bad_rcpt = array();

        if(!$this->SmtpConnect())
            return false;

        $smtp_from = ($this->Sender == "") ? $this->From : $this->Sender;
        if(!$this->smtp->Mail($smtp_from))
        {
            $error = $this->Lang("from_failed") . $smtp_from;
            $this->SetError($error);
            $this->smtp->Reset();
            return false;
        }

        // Attempt to send attach all recipients
        for($i = 0; $i < count($this->to); $i++)
        {
            if(!$this->smtp->Recipient($this->to[$i][0]))
                $bad_rcpt[] = $this->to[$i][0];
        }
        for($i = 0; $i < count($this->cc); $i++)
        {
            if(!$this->smtp->Recipient($this->cc[$i][0]))
                $bad_rcpt[] = $this->cc[$i][0];
        }
        for($i = 0; $i < count($this->bcc); $i++)
        {
            if(!$this->smtp->Recipient($this->bcc[$i][0]))
                $bad_rcpt[] = $this->bcc[$i][0];
        }

        if(count($bad_rcpt) > 0) // Create error message
        {
            for($i = 0; $i < count($bad_rcpt); $i++)
            {
                if($i != 0) { $error .= ", "; }
                $error .= $bad_rcpt[$i];
            }
            $error = $this->Lang("recipients_failed") . $error;
            $this->SetError($error);
            $this->smtp->Reset();
            return false;
        }

        if(!$this->smtp->Data($header . $body))
        {
            $this->SetError($this->Lang("data_not_accepted"));
            $this->smtp->Reset();
            return false;
        }
        if($this->SMTPKeepAlive == true)
            $this->smtp->Reset();
        else
            $this->SmtpClose();

        return true;
    }

    /**
     * Initiates a connection to an SMTP server.  Returns false if the 
     * operation failed.
     * @access private
     * @return bool
     */
    function SmtpConnect() {
        if($this->smtp == NULL) { $this->smtp = new SMTP(); }

        $this->smtp->do_debug = $this->SMTPDebug;
        $hosts = explode(";", $this->Host);
        $index = 0;
        $connection = ($this->smtp->Connected()); 

        // Retry while there is no connection
        while($index < count($hosts) && $connection == false)
        {
            if(strstr($hosts[$index], ":"))
                list($host, $port) = explode(":", $hosts[$index]);
            else
            {
                $host = $hosts[$index];
                $port = $this->Port;
            }

            if($this->smtp->Connect($host, $port, $this->Timeout))
            {
                if ($this->Helo != '')
                    $this->smtp->Hello($this->Helo);
                else
                    $this->smtp->Hello($this->ServerHostname());
        
                if($this->SMTPAuth)
                {
                    if(!$this->smtp->Authenticate($this->Username, 
                                                  $this->Password))
                    {
                        $this->SetError($this->Lang("authenticate"));
                        $this->smtp->Reset();
                        $connection = false;
                    }
                }
                $connection = true;
            }
            $index++;
        }
        if(!$connection)
            $this->SetError($this->Lang("connect_host"));

        return $connection;
    }

    /**
     * Closes the active SMTP session if one exists.
     * @return void
     */
    function SmtpClose() {
        if($this->smtp != NULL)
        {
            if($this->smtp->Connected())
            {
                $this->smtp->Quit();
                $this->smtp->Close();
            }
        }
    }

    /**
     * Sets the language for all class error messages.  Returns false 
     * if it cannot load the language file.  The default language type
     * is English.
     * @param string $lang_type Type of language (e.g. Portuguese: "br")
     * @param string $lang_path Path to the language file directory
     * @access public
     * @return bool
     */
    function SetLanguage($lang_type, $lang_path = "language/") {
        if(file_exists($lang_path.'phpmailer.lang-'.$lang_type.'.php'))
            include($lang_path.'phpmailer.lang-'.$lang_type.'.php');
        else if(file_exists($lang_path.'phpmailer.lang-en.php'))
            include($lang_path.'phpmailer.lang-en.php');
        else
        {
            $this->SetError("Could not load language file");
            return false;
        }
        $this->language = $PHPMAILER_LANG;
    
        return true;
    }

    /////////////////////////////////////////////////
    // MESSAGE CREATION METHODS
    /////////////////////////////////////////////////

    /**
     * Creates recipient headers.  
     * @access private
     * @return string
     */
    function AddrAppend($type, $addr) {
        $addr_str = $type . ": ";
        $addr_str .= $this->AddrFormat($addr[0]);
        if(count($addr) > 1)
        {
            for($i = 1; $i < count($addr); $i++)
                $addr_str .= ", " . $this->AddrFormat($addr[$i]);
        }
        $addr_str .= $this->LE;

        return $addr_str;
    }
    

I feel like I am going in circles.  There are a few files that give an unsubscribe line, or confirm your subscription, but none of them show a link to phpmynewletter.php; they give a link to subscription.php

 

Link to comment
Share on other sites

It was really long so here is the second half of the code:

 

    /**
     * Formats an address correctly. 
     * @access private
     * @return string
     */
    function AddrFormat($addr) {
        if(empty($addr[1]))
            $formatted = $addr[0];
        else
        {
            $formatted = $this->EncodeHeader($addr[1], 'phrase') . " <" . 
                         $addr[0] . ">";
        }

        return $formatted;
    }

    /**
     * Wraps message for use with mailers that do not
     * automatically perform wrapping and for quoted-printable.
     * Original written by philippe.  
     * @access private
     * @return string
     */
    function WrapText($message, $length, $qp_mode = false) {
        $soft_break = ($qp_mode) ? sprintf(" =%s", $this->LE) : $this->LE;

        $message = $this->FixEOL($message);
        if (substr($message, -1) == $this->LE)
            $message = substr($message, 0, -1);

        $line = explode($this->LE, $message);
        $message = "";
        for ($i=0 ;$i < count($line); $i++)
        {
          $line_part = explode(" ", $line[$i]);
          $buf = "";
          for ($e = 0; $e<count($line_part); $e++)
          {
              $word = $line_part[$e];
              if ($qp_mode and (strlen($word) > $length))
              {
                $space_left = $length - strlen($buf) - 1;
                if ($e != 0)
                {
                    if ($space_left > 20)
                    {
                        $len = $space_left;
                        if (substr($word, $len - 1, 1) == "=")
                          $len--;
                        elseif (substr($word, $len - 2, 1) == "=")
                          $len -= 2;
                        $part = substr($word, 0, $len);
                        $word = substr($word, $len);
                        $buf .= " " . $part;
                        $message .= $buf . sprintf("=%s", $this->LE);
                    }
                    else
                    {
                        $message .= $buf . $soft_break;
                    }
                    $buf = "";
                }
                while (strlen($word) > 0)
                {
                    $len = $length;
                    if (substr($word, $len - 1, 1) == "=")
                        $len--;
                    elseif (substr($word, $len - 2, 1) == "=")
                        $len -= 2;
                    $part = substr($word, 0, $len);
                    $word = substr($word, $len);

                    if (strlen($word) > 0)
                        $message .= $part . sprintf("=%s", $this->LE);
                    else
                        $buf = $part;
                }
              }
              else
              {
                $buf_o = $buf;
                $buf .= ($e == 0) ? $word : (" " . $word); 

                if (strlen($buf) > $length and $buf_o != "")
                {
                    $message .= $buf_o . $soft_break;
                    $buf = $word;
                }
              }
          }
          $message .= $buf . $this->LE;
        }

        return $message;
    }
    
    /**
     * Set the body wrapping.
     * @access private
     * @return void
     */
    function SetWordWrap() {
        if($this->WordWrap < 1)
            return;
            
        switch($this->message_type)
        {
           case "alt":
              // fall through
           case "alt_attachment":
              $this->AltBody = $this->WrapText($this->AltBody, $this->WordWrap);
              break;
           default:
              $this->Body = $this->WrapText($this->Body, $this->WordWrap);
              break;
        }
    }

    /**
     * Assembles message header.  
     * @access private
     * @return string
     */
    function CreateHeader() {
        $result = "";
        
        // Set the boundaries
        $uniq_id = md5(uniqid(time()));
        $this->boundary[1] = "b1_" . $uniq_id;
        $this->boundary[2] = "b2_" . $uniq_id;

        $result .= $this->HeaderLine("Date", $this->RFCDate());
        if($this->Sender == "")
            $result .= $this->HeaderLine("Return-Path", trim($this->From));
        else
            $result .= $this->HeaderLine("Return-Path", trim($this->Sender));
        
        // To be created automatically by mail()
        if($this->Mailer != "mail")
        {
            if(count($this->to) > 0)
                $result .= $this->AddrAppend("To", $this->to);
            else if (count($this->cc) == 0)
                $result .= $this->HeaderLine("To", "undisclosed-recipients:;");
            if(count($this->cc) > 0)
                $result .= $this->AddrAppend("Cc", $this->cc);
        }

        $from = array();
        $from[0][0] = trim($this->From);
        $from[0][1] = $this->FromName;
        $result .= $this->AddrAppend("From", $from); 

        // sendmail and mail() extract Bcc from the header before sending
        if((($this->Mailer == "sendmail") || ($this->Mailer == "mail")) && (count($this->bcc) > 0))
            $result .= $this->AddrAppend("Bcc", $this->bcc);

        if(count($this->ReplyTo) > 0)
            $result .= $this->AddrAppend("Reply-to", $this->ReplyTo);

        // mail() sets the subject itself
        if($this->Mailer != "mail")
            $result .= $this->HeaderLine("Subject", $this->EncodeHeader(trim($this->Subject)));

        $result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE);
        $result .= $this->HeaderLine("X-Priority", $this->Priority);
        $result .= $this->HeaderLine("X-Mailer", "PHPMailer [version " . $this->Version . "]");
        
        if($this->ConfirmReadingTo != "")
        {
            $result .= $this->HeaderLine("Disposition-Notification-To", 
                       "<" . trim($this->ConfirmReadingTo) . ">");
        }

        // Add custom headers
        for($index = 0; $index < count($this->CustomHeader); $index++)
        {
            $result .= $this->HeaderLine(trim($this->CustomHeader[$index][0]), 
                       $this->EncodeHeader(trim($this->CustomHeader[$index][1])));
        }
        $result .= $this->HeaderLine("MIME-Version", "1.0");

        switch($this->message_type)
        {
            case "plain":
                $result .= $this->HeaderLine("Content-Transfer-Encoding", $this->Encoding);
                $result .= sprintf("Content-Type: %s; charset=\"%s\"",
                                    $this->ContentType, $this->CharSet);
                break;
            case "attachments":
                // fall through
            case "alt_attachments":
                if($this->InlineImageExists())
                {
                    $result .= sprintf("Content-Type: %s;%s\ttype=\"text/html\";%s\tboundary=\"%s\"%s", 
                                    "multipart/related", $this->LE, $this->LE, 
                                    $this->boundary[1], $this->LE);
                }
                else
                {
                    $result .= $this->HeaderLine("Content-Type", "multipart/mixed;");
                    $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
                }
                break;
            case "alt":
                $result .= $this->HeaderLine("Content-Type", "multipart/alternative;");
                $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
                break;
        }

        if($this->Mailer != "mail")
            $result .= $this->LE.$this->LE;

        return $result;
    }

    /**
     * Assembles the message body.  Returns an empty string on failure.
     * @access private
     * @return string
     */
    function CreateBody() {
        $result = "";

        $this->SetWordWrap();

        switch($this->message_type)
        {
            case "alt":
                $result .= $this->GetBoundary($this->boundary[1], "", 
                                              "text/plain", "");
                $result .= $this->EncodeString($this->AltBody, $this->Encoding);
                $result .= $this->LE.$this->LE;
                $result .= $this->GetBoundary($this->boundary[1], "", 
                                              "text/html", "");
                
                $result .= $this->EncodeString($this->Body, $this->Encoding);
                $result .= $this->LE.$this->LE;
    
                $result .= $this->EndBoundary($this->boundary[1]);
                break;
            case "plain":
                $result .= $this->EncodeString($this->Body, $this->Encoding);
                break;
            case "attachments":
                $result .= $this->GetBoundary($this->boundary[1], "", "", "");
                $result .= $this->EncodeString($this->Body, $this->Encoding);
                $result .= $this->LE;
     
                $result .= $this->AttachAll();
                break;
            case "alt_attachments":
                $result .= sprintf("--%s%s", $this->boundary[1], $this->LE);
                $result .= sprintf("Content-Type: %s;%s" .
                                   "\tboundary=\"%s\"%s",
                                   "multipart/alternative", $this->LE, 
                                   $this->boundary[2], $this->LE.$this->LE);
    
                // Create text body
                $result .= $this->GetBoundary($this->boundary[2], "", 
                                              "text/plain", "") . $this->LE;

                $result .= $this->EncodeString($this->AltBody, $this->Encoding);
                $result .= $this->LE.$this->LE;
                    // Create the HTML body
                $result .= $this->GetBoundary($this->boundary[2], "", 
                                              "text/html", "") . $this->LE;
    
                $result .= $this->EncodeString($this->Body, $this->Encoding);
                $result .= $this->LE.$this->LE;
                $result .= $this->EndBoundary($this->boundary[2]);
   
                $result .= $this->AttachAll();
                break;
        }
        if($this->IsError())
            $result = "";

        return $result;
    }

    /**
     * Returns the start of a message boundary.
     * @access private
     */
    function GetBoundary($boundary, $charSet, $contentType, $encoding) {
        $result = "";
        if($charSet == "") { $charSet = $this->CharSet; }
        if($contentType == "") { $contentType = $this->ContentType; }
        if($encoding == "") { $encoding = $this->Encoding; }

        $result .= $this->TextLine("--" . $boundary);
        $result .= sprintf("Content-Type: %s; charset = \"%s\"", 
                            $contentType, $charSet);
        $result .= $this->LE;
        $result .= $this->HeaderLine("Content-Transfer-Encoding", $encoding);
        $result .= $this->LE;
       
        return $result;
    }
    
    /**
     * Returns the end of a message boundary.
     * @access private
     */
    function EndBoundary($boundary) {
        return $this->LE . "--" . $boundary . "--" . $this->LE; 
    }
    
    /**
     * Sets the message type.
     * @access private
     * @return void
     */
    function SetMessageType() {
        if(count($this->attachment) < 1 && strlen($this->AltBody) < 1)
            $this->message_type = "plain";
        else
        {
            if(count($this->attachment) > 0)
                $this->message_type = "attachments";
            if(strlen($this->AltBody) > 0 && count($this->attachment) < 1)
                $this->message_type = "alt";
            if(strlen($this->AltBody) > 0 && count($this->attachment) > 0)
                $this->message_type = "alt_attachments";
        }
    }

    /**
     * Returns a formatted header line.
     * @access private
     * @return string
     */
    function HeaderLine($name, $value) {
        return $name . ": " . $value . $this->LE;
    }

    /**
     * Returns a formatted mail line.
     * @access private
     * @return string
     */
    function TextLine($value) {
        return $value . $this->LE;
    }

    /**
     * Adds an attachment from a path on the filesystem.
     * Returns false if the file could not be found
     * or accessed.
     * @param string $path Path to the attachment.
     * @param string $name Overrides the attachment name.
     * @param string $encoding File encoding (see $Encoding).
     * @param string $type File extension (MIME) type.
     * @return bool
     */
    function AddAttachment($path, $name = "", $encoding = "base64", 
                           $type = "application/octet-stream") {
        if(!@is_file($path))
        {
            $this->SetError($this->Lang("file_access") . $path);
            return false;
        }

        $filename = basename($path);
        if($name == "")
            $name = $filename;

        $cur = count($this->attachment);
        $this->attachment[$cur][0] = $path;
        $this->attachment[$cur][1] = $filename;
        $this->attachment[$cur][2] = $name;
        $this->attachment[$cur][3] = $encoding;
        $this->attachment[$cur][4] = $type;
        $this->attachment[$cur][5] = false; // isStringAttachment
        $this->attachment[$cur][6] = "attachment";
        $this->attachment[$cur][7] = 0;

        return true;
    }

    /**
     * Attaches all fs, string, and binary attachments to the message.
     * Returns an empty string on failure.
     * @access private
     * @return string
     */
    function AttachAll() {
        // Return text of body
        $mime = array();

        // Add all attachments
        for($i = 0; $i < count($this->attachment); $i++)
        {
            // Check for string attachment
            $bString = $this->attachment[$i][5];
            if ($bString)
                $string = $this->attachment[$i][0];
            else
                $path = $this->attachment[$i][0];

            $filename    = $this->attachment[$i][1];
            $name        = $this->attachment[$i][2];
            $encoding    = $this->attachment[$i][3];
            $type        = $this->attachment[$i][4];
            $disposition = $this->attachment[$i][6];
            $cid         = $this->attachment[$i][7];
            
            $mime[] = sprintf("--%s%s", $this->boundary[1], $this->LE);
            $mime[] = sprintf("Content-Type: %s; name=\"%s\"%s", $type, $name, $this->LE);
            $mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, $this->LE);

            if($disposition == "inline")
                $mime[] = sprintf("Content-ID: <%s>%s", $cid, $this->LE);

            $mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s", 
                              $disposition, $name, $this->LE.$this->LE);

            // Encode as string attachment
            if($bString)
            {
                $mime[] = $this->EncodeString($string, $encoding);
                if($this->IsError()) { return ""; }
                $mime[] = $this->LE.$this->LE;
            }
            else
            {
                $mime[] = $this->EncodeFile($path, $encoding);                
                if($this->IsError()) { return ""; }
                $mime[] = $this->LE.$this->LE;
            }
        }

        $mime[] = sprintf("--%s--%s", $this->boundary[1], $this->LE);

        return join("", $mime);
    }
    
    /**
     * Encodes attachment in requested format.  Returns an
     * empty string on failure.
     * @access private
     * @return string
     */
    function EncodeFile ($path, $encoding = "base64") {
        if(!@$fd = fopen($path, "rb"))
        {
            $this->SetError($this->Lang("file_open") . $path);
            return "";
        }
        $file_buffer = fread($fd, filesize($path));
        $file_buffer = $this->EncodeString($file_buffer, $encoding);
        fclose($fd);

        return $file_buffer;
    }

    /**
     * Encodes string to requested format. Returns an
     * empty string on failure.
     * @access private
     * @return string
     */
    function EncodeString ($str, $encoding = "base64") {
        $encoded = "";
        switch(strtolower($encoding)) {
          case "base64":
              // chunk_split is found in PHP >= 3.0.6
              $encoded = chunk_split(base64_encode($str), 76, $this->LE);
              break;
          case "7bit":
          case "8bit":
              $encoded = $this->FixEOL($str);
              if (substr($encoded, -(strlen($this->LE))) != $this->LE)
                $encoded .= $this->LE;
              break;
          case "binary":
              $encoded = $str;
              break;
          case "quoted-printable":
              $encoded = $this->EncodeQP($str);
              break;
          default:
              $this->SetError($this->Lang("encoding") . $encoding);
              break;
        }
        return $encoded;
    }

    /**
     * Encode a header string to best of Q, B, quoted or none.  
     * @access private
     * @return string
     */
    function EncodeHeader ($str, $position = 'text') {
      $x = 0;
      
      switch (strtolower($position)) {
        case 'phrase':
          if (!preg_match('/[\200-\377]/', $str)) {
            // Can't use addslashes as we don't know what value has magic_quotes_sybase.
            $encoded = addcslashes($str, "\0..\37\177\\\"");

            if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str))
              return ($encoded);
            else
              return ("\"$encoded\"");
          }
          $x = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches);
          break;
        case 'comment':
          $x = preg_match_all('/[()"]/', $str, $matches);
          // Fall-through
        case 'text':
        default:
          $x += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches);
          break;
      }

      if ($x == 0)
        return ($str);

      $maxlen = 75 - 7 - strlen($this->CharSet);
      // Try to select the encoding which should produce the shortest output
      if (strlen($str)/3 < $x) {
        $encoding = 'B';
        $encoded = base64_encode($str);
        $maxlen -= $maxlen % 4;
        $encoded = trim(chunk_split($encoded, $maxlen, "\n"));
      } else {
        $encoding = 'Q';
        $encoded = $this->EncodeQ($str, $position);
        $encoded = $this->WrapText($encoded, $maxlen, true);
        $encoded = str_replace("=".$this->LE, "\n", trim($encoded));
      }

      $encoded = preg_replace('/^(.*)$/m', " =?".$this->CharSet."?$encoding?\\1?=", $encoded);
      $encoded = trim(str_replace("\n", $this->LE, $encoded));
      
      return $encoded;
    }
    
    /**
     * Encode string to quoted-printable.  
     * @access private
     * @return string
     */
    function EncodeQP ($str) {
        $encoded = $this->FixEOL($str);
        if (substr($encoded, -(strlen($this->LE))) != $this->LE)
            $encoded .= $this->LE;

        // Replace every high ascii, control and = characters
        $encoded = preg_replace('/([\000-\010\013\014\016-\037\075\177-\377])/e',
                  "'='.sprintf('%02X', ord('\\1'))", $encoded);
        // Replace every spaces and tabs when it's the last character on a line
        $encoded = preg_replace("/([\011\040])".$this->LE."/e",
                  "'='.sprintf('%02X', ord('\\1')).'".$this->LE."'", $encoded);

        // Maximum line length of 76 characters before CRLF (74 + space + '=')
        $encoded = $this->WrapText($encoded, 74, true);

        return $encoded;
    }

    /**
     * Encode string to q encoding.  
     * @access private
     * @return string
     */
    function EncodeQ ($str, $position = "text") {
        // There should not be any EOL in the string
        $encoded = preg_replace("[\r\n]", "", $str);

        switch (strtolower($position)) {
          case "phrase":
            $encoded = preg_replace("/([^A-Za-z0-9!*+\/ -])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
            break;
          case "comment":
            $encoded = preg_replace("/([\(\)\"])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
          case "text":
          default:
            // Replace every high ascii, control =, ? and _ characters
            $encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e',
                  "'='.sprintf('%02X', ord('\\1'))", $encoded);
            break;
        }
        
        // Replace every spaces to _ (more readable than =20)
        $encoded = str_replace(" ", "_", $encoded);

        return $encoded;
    }

    /**
     * Adds a string or binary attachment (non-filesystem) to the list.
     * This method can be used to attach ascii or binary data,
     * such as a BLOB record from a database.
     * @param string $string String attachment data.
     * @param string $filename Name of the attachment.
     * @param string $encoding File encoding (see $Encoding).
     * @param string $type File extension (MIME) type.
     * @return void
     */
    function AddStringAttachment($string, $filename, $encoding = "base64", 
                                 $type = "application/octet-stream") {
        // Append to $attachment array
        $cur = count($this->attachment);
        $this->attachment[$cur][0] = $string;
        $this->attachment[$cur][1] = $filename;
        $this->attachment[$cur][2] = $filename;
        $this->attachment[$cur][3] = $encoding;
        $this->attachment[$cur][4] = $type;
        $this->attachment[$cur][5] = true; // isString
        $this->attachment[$cur][6] = "attachment";
        $this->attachment[$cur][7] = 0;
    }
    
    /**
     * Adds an embedded attachment.  This can include images, sounds, and 
     * just about any other document.  Make sure to set the $type to an 
     * image type.  For JPEG images use "image/jpeg" and for GIF images 
     * use "image/gif".
     * @param string $path Path to the attachment.
     * @param string $cid Content ID of the attachment.  Use this to identify 
     *        the Id for accessing the image in an HTML form.
     * @param string $name Overrides the attachment name.
     * @param string $encoding File encoding (see $Encoding).
     * @param string $type File extension (MIME) type.  
     * @return bool
     */
    function AddEmbeddedImage($path, $cid, $name = "", $encoding = "base64", 
                              $type = "application/octet-stream") {
    
        if(!@is_file($path))
        {
            $this->SetError($this->Lang("file_access") . $path);
            return false;
        }

        $filename = basename($path);
        if($name == "")
            $name = $filename;

        // Append to $attachment array
        $cur = count($this->attachment);
        $this->attachment[$cur][0] = $path;
        $this->attachment[$cur][1] = $filename;
        $this->attachment[$cur][2] = $name;
        $this->attachment[$cur][3] = $encoding;
        $this->attachment[$cur][4] = $type;
        $this->attachment[$cur][5] = false; // isStringAttachment
        $this->attachment[$cur][6] = "inline";
        $this->attachment[$cur][7] = $cid;
    
        return true;
    }
    
    /**
     * Returns true if an inline attachment is present.
     * @access private
     * @return bool
     */
    function InlineImageExists() {
        $result = false;
        for($i = 0; $i < count($this->attachment); $i++)
        {
            if($this->attachment[$i][6] == "inline")
            {
                $result = true;
                break;
            }
        }
        
        return $result;
    }

    /////////////////////////////////////////////////
    // MESSAGE RESET METHODS
    /////////////////////////////////////////////////

    /**
     * Clears all recipients assigned in the TO array.  Returns void.
     * @return void
     */
    function ClearAddresses() {
        $this->to = array();
    }

    /**
     * Clears all recipients assigned in the CC array.  Returns void.
     * @return void
     */
    function ClearCCs() {
        $this->cc = array();
    }

    /**
     * Clears all recipients assigned in the BCC array.  Returns void.
     * @return void
     */
    function ClearBCCs() {
        $this->bcc = array();
    }

    /**
     * Clears all recipients assigned in the ReplyTo array.  Returns void.
     * @return void
     */
    function ClearReplyTos() {
        $this->ReplyTo = array();
    }

    /**
     * Clears all recipients assigned in the TO, CC and BCC
     * array.  Returns void.
     * @return void
     */
    function ClearAllRecipients() {
        $this->to = array();
        $this->cc = array();
        $this->bcc = array();
    }

    /**
     * Clears all previously set filesystem, string, and binary
     * attachments.  Returns void.
     * @return void
     */
    function ClearAttachments() {
        $this->attachment = array();
    }

    /**
     * Clears all custom headers.  Returns void.
     * @return void
     */
    function ClearCustomHeaders() {
        $this->CustomHeader = array();
    }


    //
    // MISCELLANEOUS METHODS
    ///

    /**
     * Adds the error message to the error container.
     * Returns void.
     * @access private
     * @return void
     */
    function SetError($msg) {
        $this->error_count++;
        $this->ErrorInfo = $msg;
    }

    /**
     * Returns the proper RFC 822 formatted date. 
     * @access private
     * @return string
     */
    function RFCDate() {
        $tz = date("Z");
        $tzs = ($tz < 0) ? "-" : "+";
        $tz = abs($tz);
        $tz = ($tz/3600)*100 + ($tz%3600)/60;
        $result = sprintf("%s %s%04d", date("D, j M Y H:i:s"), $tzs, $tz);

        return $result;
    }
    
    /**
     * Returns the appropriate server variable.  Should work with both 
     * PHP 4.1.0+ as well as older versions.  Returns an empty string 
     * if nothing is found.
     * @access private
     * @return mixed
     */
    function ServerVar($varName) {
        global $HTTP_SERVER_VARS;
        global $HTTP_ENV_VARS;

        if(!isset($_SERVER))
        {
            $_SERVER = $HTTP_SERVER_VARS;
            if(!isset($_SERVER["REMOTE_ADDR"]))
                $_SERVER = $HTTP_ENV_VARS; // must be Apache
        }
        
        if(isset($_SERVER[$varName]))
            return $_SERVER[$varName];
        else
            return "";
    }

    /**
     * Returns the server hostname or 'localhost.localdomain' if unknown.
     * @access private
     * @return string
     */
    function ServerHostname() {
        if ($this->Hostname != "")
            $result = $this->Hostname;
        elseif ($this->ServerVar('SERVER_NAME') != "")
            $result = $this->ServerVar('SERVER_NAME');
        else
            $result = "localhost.localdomain";

        return $result;
    }

    /**
     * Returns a message in the appropriate language.
     * @access private
     * @return string
     */
    function Lang($key) {
        if(count($this->language) < 1)
            $this->SetLanguage("en"); // set the default language
    
        if(isset($this->language[$key]))
            return $this->language[$key];
        else
            return "Language string failed to load: " . $key;
    }
    
    /**
     * Returns true if an error occurred.
     * @return bool
     */
    function IsError() {
        return ($this->error_count > 0);
    }

    /**
     * Changes every end of line from CR or LF to CRLF.  
     * @access private
     * @return string
     */
    function FixEOL($str) {
        $str = str_replace("\r\n", "\n", $str);
        $str = str_replace("\r", "\n", $str);
        $str = str_replace("\n", $this->LE, $str);
        return $str;
    }

    /**
     * Adds a custom header. 
     * @return void
     */
    function AddCustomHeader($custom_header) {
        $this->CustomHeader[] = explode(":", $custom_header, 2);
    }
}

?>

Link to comment
Share on other sites

libnewsletter.php

<?
//16/05/2002 <gregory.kokanosky@free.fr>
// phpMyNewsletter v0.8.x

// a class for managing Newsletter

if (!defined( "_NEWSLETTER_LIB" ))
{
  define("_NEWSLETTER_LIB", 1);
  

  function validEmailAddress($email){
    // regx to test for valid e-mail adres
    $regex = '^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]{2,})+$';
    if (eregi($regex, $email)) return true;
    else return false;
    
  }

  class Newsletter {
    
  var $list_id;
  var $name; //name of the newsletter
  
  var $from;
  var $from_name;

  var $subscription_subject;
  var $subscription_body;
  var $welcome_subject;
  var $welcome_body;
  var $quit_subject;
  var $quit_body;
  
  var $subject;
  var $header;
  var $footer;

  var $db_host;
  var $db_login;
  var $db_pass;
  var $db_name;

  
  function getConfig($host, $login, $pass, $database, $list_id , $list_table){
    $this->list_id = $list_id;
    $db= new Db();
    $db->DbConnect($host, $login, $pass, $database);
    $db->DbQuery("SELECT * FROM $list_table WHERE list_id='$list_id'");
    $conf = $db->DbNextRow();
    
    $this->db_host =$host;
    $this->db_login=$login;
    $this->db_pass =$pass;
    $this->db_name =$database;
    
    $this->name= $conf[1];
    $this->from= $conf[2];
    $this->from_name = $conf[3];
    $this->subject= $conf[4];
    $this->header = $conf[5];
    $this->footer = $conf[6];
    $this->subscription_subject = $conf[7];
    $this->subscription_body = $conf[8];
    $this->welcome_subject = $conf[9];
    $this->welcome_body = $conf[10];
    $this->quit_subject = $conf[11];
    $this->quit_body = $conf[12];
  }
  

  function getAddress($mail_table, $begin='', $limit='')
    {
      $Addr = array();
      $db= new Db();
      $db->DbConnect($this->db_host, $this->db_login, $this->db_pass, $this->db_name);
      $sql = "SELECT email FROM $mail_table WHERE list_id='$this->list_id'";
      $db->DbQuery($sql ,$begin, $limit, 1);
      for($i=0; $i<$db->DbNumRows(); $i++){
$addr = $db->DbNextRow();
$Addr[$i]=$addr[0];
      }
      return $Addr;
    }
  

  
  function saveConfig($db_host, $db_login, $db_pass, $db_name, $list_id, $table_listsconfig, $newsletter_name, $from, $from_name, $subject, $header, $footer, $subscription_subject, $subscription_body, $welcome_subject, $welcome_body, $quit_subject, $quit_body){
    
    $db= new Db();
    $db->DbConnect($db_host, $db_login, $db_pass, $db_name);
if(!get_magic_quotes_gpc()){
  $newsletter_name = escape_string($newsletter_name);
  $from = escape_string($from);
  $from_name = escape_string($from_name);
  $subject = escape_string($subject);
  $header = escape_string($header);
  $footer = escape_string($footer);
  $subscription_subject = escape_string($subscription_subject);
  $subscription_body = escape_string($subscription_body);
  $welcome_subject = escape_string($welcome_subject);
  $welcome_body = escape_string($welcome_body);
  $quit_subject = escape_string($quit_subject);
  $quit_body =escape_string($quit_body);
}
    
    $sql ="UPDATE $table_listsconfig SET newsletter_name=\"$newsletter_name\", from_addr=\"$from\", from_name=\"$from_name\", subject=\"$subject\", header=\"$header\" , footer=\"$footer\" , subscription_subject=\"$subscription_subject\", subscription_body=\"$subscription_body\", welcome_subject=\"$welcome_subject\", welcome_body=\"$welcome_body\", quit_subject=\"$quit_subject\", quit_body=\"$quit_body\" WHERE list_id='$list_id'";


    $db->DbQuery($sql);
    if($db->DbError()) return 0;
    else return 1;
        
  }



  


  function getSubscribersNumbers($table_email){
      $db= new Db();
      $db->DbConnect($this->db_host, $this->db_login, $this->db_pass, $this->db_name);
      $db->DbQuery("SELECT COUNT(*) FROM $table_email WHERE list_id='$this->list_id'");
      $num = $db->DbNextRow();
      return $num[0];
  }	
  



  function deleteArchive($table_archives, $msg_id){
      $db= new Db();
      $db->DbConnect($this->db_host, $this->db_login, $this->db_pass, $this->db_name);
      $db->DbQuery("DELETE FROM $table_archives  WHERE id='$msg_id'");
      if($db->DbError()) return 0;
      else return 1;
  }


  function getArchivesSelectList($table_archives, $msg_id='', $form_name='archive_form2'){
      $db= new Db();
      $db->DbConnect($this->db_host, $this->db_login, $this->db_pass, $this->db_name);
      $sql = "SELECT id, date, subject FROM $table_archives WHERE list_id='$this->list_id' ORDER BY date DESC";
      $db->DbQuery($sql);
      if($db->DbNumRows() == 0) return -1;
      else {
  echo "<select name=\"msg_id\" onchange=\"document.$form_name.submit()\">\n";
  while($archives = $db->DBNextRow())
    {

      echo "<option value=\"$archives[0]\" ";
      if ($msg_id==$archives[0]) echo "selected='selected'";
      echo ">".stripslashes(htmlspecialchars($archives[2]))." </option>\n";
    } 
  echo "</select>";
  
}

    }
  

  function getArchiveMsg($table_archives, $msg_id)
    {
      if( empty($offset)) $offset=0;
      $db= new Db();
      $db->DbConnect($this->db_host, $this->db_login, $this->db_pass, $this->db_name);
      $sql = "SELECT date, type, subject, message FROM $table_archives WHERE id='$msg_id'";
      $db->DbQuery($sql);
      if($db->DbNumRows() == 0) return -1;
      else{
  $archive = $db->DbNextRow();
  echo "<div class='subsection' >";
  $subject = htmlspecialchars($archive[2]);
  $subject = stripslashes($subject);
          $date = $archive[0];
  echo "<div class='archivetitle'>".$subject." - ".$date."</div>";
  //echo translate("ARCHIVE_SUBJECT").": ".$subject."<br />\n";
  //echo translate("ARCHIVE_DATE").": ".$archive[0]."<br />\n";
  //echo translate("ARCHIVE_FORMAT").": ".$archive[1]."<br /><br />\n";
  echo "<div class='subcontent'>";
          
          if($archive[1] != "html"){ 
  $body = str_replace("<","<", $archive[3]);
  $body = str_replace(">",">", $body);
  
  $body = nl2br(stripslashes($body));
          } else {
	$body = stripslashes( $archive[3] );
          } 
  echo "\t".$body;

  echo "</div></div>\n";
  echo "<br />";
}
      
    }


  
  }
}


?>

Link to comment
Share on other sites

Hmm I think the email's stored in the DB. Can you check the DB? Look for anything that looks like the email. Don't just search for that one filename. Try searching for anything related to the email. You should have the message to compare it to.

Link to comment
Share on other sites

I looked through all the files that I could see and did not find anything, but will spend some time later looking again.  I will let you know what I find. 

Thank you so much for all the time that you are spending looking at this.

 

Rachel

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.