9 Replies - 5668 Views - Last Post: 12 May 2008 - 12:36 PM Rate Topic: -----

#1 philb   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 26-April 08

Hosting Company php5 issue

Posted 26 April 2008 - 11:17 AM

UK based hosting company Streamline.net upgraded its php5 functions recently and suddenly all forms (developed with coffecup form builder) of my 30+ clients have stopped working !! :-( Streamline state a fifth parameter needs to be included in the php code. There response to me was:
Send mail path /usr/sbin/sendmail -fuser\@yourdomain.co.uk
You need to replace -fuser\@domain.co.uk with a valid mailbox on your account: i.e) -froot\@domain.co.uk
An example of how to use this is as follows:
mail($to, $sub, $mess, "From: [email protected]", "[email protected]");

The strange thing is my own website form is working ok!! just my clients sites, very odd. They were all working fine before streamline cocked the webserver up. Any advice on if and how it may be possible to get the forms working. Please PHP Gurus it would be appriciated so so much. Sorry the code is a little long winded! Any help on how and where I could fix this would be great.

Thanks in advance
Phil Brighton
p.s Here is a URL to show a form, http://www.secret-garden-york.co.uk its a little naff but you can see it looks like it has submitted but the info never gets to the streamline webmail account. By the way, if I send to a form to a hotmail account it works fine! Double grrrrr!!

Here is the php code of a form:

[code]
<?php
/**
* CoffeeCup Flash Form Builder: Form Results Handler
*
* This file is in charge of handling the form results
* posted from the CoffeeCup Flash Form Builder SWF.
* It has several primary functions:
*
* - Assure that the user is running the proper version of
* PHP and has properly configured their server for
* CoffeeCup Flash Form Builder by uploading the provided
* files and assigning the appropriate server settings
* and permissions.
* - Upload a file if the '$_FILES['Filedata']' variable is
* populated
* - If the '$_POST' superglobal array has been populated,
* process the form by:
* - Reading the config file provided in the '$_POST['xmlfile']'
* variable.
* - Saving the form data to a file if the 'CC_FB_SAVE_FILE' constant
* has been populated.
* - Saving the form data to the database provided in 'CC_FB_DB_ADDRESS'
* if the 'CC_FB_DB_ADDRESS' constant is populated.
* - Emailing the form data to the form owner via the address provided
* in the '$_POST['_ALT_EMAIL']' variable or the '$_POST['mailto']'
* variable if the '$_POST['_ALT_EMAIL']' variable is not populated.
* - Emailing the form data to the form user via the address provided in
* the '$_POST['eM']' variable if the '$_POST['eM']' variable has been
* populated and the 'emailuser' config option is set to 'true'.
* - Taking the form user to the landing page provided in the
* '$_POST['thankyoupage']' variable or to a default landing page
* if the '$_POST['thankyoupage']' is empty.
* - Prints out an informational page with version numbers and release
* dates if an error occurs or if this script is called without
* the '$_POST' superglobal or the '$_FILES['Filedata']' variables
* being set.
*
* @license [url=http://www.coffeecup.com/legal/eula.html]http://www.coffeecup.com/legal/eula.html[/url]
* @author Jeff Welch <[email protected]>
* @version 4.0
* @package CC_FB
*/

// Error reporting should be disabled in favor of
// our customer error messages.
error_reporting(0);

/**
* The version of CoffeeCup Flash Form Builder that
* generated this script.
*/
define('CC_FB_VERSION', '7.1');
/**
* The release date of the version of CoffeeCup Flash Form
* Builder that generated this script.
*/
define('CC_FB_LAST_UPDATED', '08/31/2007');

/**
* The version of this script.
*/
define('CC_FB_SCRIPT_VERSION', '4.0');
/**
* The release date of this script.
*/
define('CC_FB_SCRIPT_LAST_UPDATED', '09/07/2007');

/**
* The required PHP version for this script.
*/
define('CC_FB_PHP_VERSION', '4.3.0');

/**
* Will the owner of this form be emailed the
* form data
*/
define('CC_FB_DO_EMAIL',true);
/**
* To default To address.
*/
define('CC_FB_TO_EMAIL', '[email protected]');
/**
* The default CC address.
*/
define('CC_FB_CC_EMAIL', '');
/**
* The default BCC address.
*/
define('CC_FB_BCC_EMAIL', '');

/**
* If we should send a message back to the user.
*/
define('CC_FB_AUTO_REPLY', false);
/**
* The subject of the message to be sent to the user.
*/
define('CC_FB_AUTO_REPLY_SUBJECT', '');
/**
* If we should include the form results
* in the message we send to the user.
*/
define('CC_FB_AUTO_REPLY_FORM_RESULTS', false);
/**
* The position of the auto-reply message
* in the email.
*/
define('CC_FB_AUTO_REPLY_POSITION', 'bottom');

/**
* The page to redirect to after the form is submitted.
*/
define('CC_FB_RESULTS_REDIRECT', 'http://www.secret-garden-york.co.uk/thanks.htm');

/**
* The address of the database where the form results
* will be saved.
*/
define('CC_FB_DB_ADDRESS', '[ADDRESS]');
/**
* The port number of the database where the form results
* will be saved.
*/
define('CC_FB_DB_PORT', '[DBPORT]');
/**
* The username for the database where the form results
* will be saved.
*/
define('CC_FB_DB_USERNAME', '[DBUSER]');
/**
* The password for the database where the form results
* will be saved.
*/
define('CC_FB_DB_PASSWORD', '[DBPASS]');
/**
* The name of the database where the form results
* will be saved.
*/
define('CC_FB_DB_NAME', '[DBNAME]');

/**
* The file to log the form results to if necessary.
*/
define('CC_FB_SAVE_FILE', '[FILENAME]');

/**
* The filetypes that are acceptable for file uploads.
*/
define('CC_FB_ACCEPTABLE_FILE_TYPES', 'txt|gif|jpg|jpeg|zip|doc|png|pdf|rtf');
/**
* The directory where files are uploaded
*/
define('CC_FB_UPLOADS_DIRECTORY', 'files');
/**
* The extension that gets added to file uploads
*/
define('CC_FB_UPLOADS_EXTENSION', '_fbu');
/**
* Will we save the file uploads to the server
*/
define('CC_FB_ATTACHMENT_SAVETOSERVER',true);
/**
* Will we save the file uploads to the db
*/
define('CC_FB_ATTACHMENT_SAVETODB',false);
/**
* Will we send the file upload as an attachment
*/
define('CC_FB_ATTACHMENT_ADDTOEMAIL',false);
/**
* Sendmail Message EOL's
*/
define('CC_FB_SENDMAIL_EOL',"\r\n");

// Makes sure that the user is using the required version
// of PHP as specified by {@link CC_FB_PHP_VERSION}.
if(!version_compare(PHP_VERSION, CC_FB_PHP_VERSION, '>='))
{
printMessage('Invalid PHP Version',
"We're sorry but CoffeeCup Form Builder requires PHP version " .
CC_FB_PHP_VERSION . ' or greater. Please contact your server ' .
'administrator.');
}
// Strip slashes if the server has magic quotes enabled.
if(get_magic_quotes_gpc())
{
$_POST = array_map("stripslashes", $_POST);
}
// John will need to fix this in the swf file.
foreach($_POST as $key => $value)
{
$_POST[str_replace('_', ' ', $key)] = $value;
}

// If the '$_FILES['Filedata']' is populated, process the
// file upload.
if(isset($_FILES['Filedata']))
{
processFileUpload();
}
// If the '$_POST' superglobal array is populated,
// process the form results.
elseif(is_array($_POST) && count($_POST) > 0)
{
processMailForm();
}
// If all else fails, print out a blank page with version
// numbers and release dates.
printMessage();


/**
* Process the mail form results.
*
* This method is in charge of processing the mail form which
* is posted from the CoffeeCup Flash Form Builder SWF. This
* process includes:
*
* - Retrieving the preferences from the included CoffeeCup Flash
* Form Builder XML preferences file.
* - Formats output for file output as well as for an email to
* the form user and the form owner as necesarry.
* - Writes output to a file and sends it to the form user and
* the form owner as necessary.
* - Writes form results to a database if necesarry.
*/
function processMailForm()
{
fixUploadedFileName();
$preferences = getPreferences();

foreach($preferences['form_fields'] as $key => $value)
{
$email_response .= "$key: {$_POST[$key]}" .
CC_FB_SENDMAIL_EOL . CC_FB_SENDMAIL_EOL;
$form_response .= "$key: {$_POST[$key]}<br/>\n";
$txt_file .= "$key: {$_POST[$key]}|";
}

// If a file was uploaded, add the appropriate data to the response
// fields
if($_POST['Uploaded_File'] != "")
{
$email_response .= "Uploaded File: {$_POST['Uploaded_File']}" .
CC_FB_SENDMAIL_EOL . CC_FB_SENDMAIL_EOL;
$form_response .= " Uploaded File: {$_POST['Uploaded_File']}" .
"<br/>\n";
$txt_file .= "Uploaded File: {$_POST['Uploaded_File']}|";
}

sendResponseEmails($email_response, $preferences);
writeResponseToFile($txt_file);
writeResponseToDatabase($preferences);

// Make sure we delete the file from the server if the user doesn't
// want it
if(!CC_FB_ATTACHMENT_SAVETOSERVER && $_POST['Uploaded_File'] != '')
{
@unlink(CC_FB_UPLOADS_DIRECTORY . "/{$_POST['Uploaded_File']}");
}

printResponsePage($form_response, $preferences);
}


/**
* Send response emails to the appropriate recipients.
*
* Sends an email to the scripts owner as well as the end-user
* if appropriate. If the sending of mail fails, an error
* message will be printed out to the screen.
*
* @param string $email_response the default contents to mail to the user.
* @param array $preferences the CoffeeCup Flash Form Builder Preferences.
*/
function sendResponseEmails($email_response, $preferences)
{
// If the program is unregistered, add the unregistered message.
if($_POST['unreg'])
{
$unreg = "------------------------" .
CC_FB_SENDMAIL_EOL . CC_FB_SENDMAIL_EOL .
"This Form was sent to you using CoffeeCup Form Builder." .
CC_FB_SENDMAIL_EOL . "Please tell a " .
"friend about us: [url=http://www.coffeecup.com/form-builder/";]http://www.coffeecup.com/form-builder/";[/url]
}

// Set up the CC field if necessary
if(CC_FB_CC_EMAIL != '')
{
$cc = 'Cc: ' . CC_FB_CC_EMAIL . CC_FB_SENDMAIL_EOL;
}

// Set up the BCC field if necessary
if(CC_FB_BCC_EMAIL != '')
{
$bcc = 'Bcc: ' . CC_FB_BCC_EMAIL . CC_FB_SENDMAIL_EOL;
}

// Use the alternative email if one is provided
$mail_to = ($_POST['_ALT_EMAIL'] != '' ? $_POST['_ALT_EMAIL'] :
CC_FB_TO_EMAIL);

// Set a default subject if one is not provided provided
$subject = ($_POST['subject'] != '' ? $_POST['subject'] :
'Form Submission');

// Set up the default mail headers
$headers = 'MIME-Version: 1.0' . CC_FB_SENDMAIL_EOL .
'Content-Type: text/plain; charset=utf-8' . CC_FB_SENDMAIL_EOL .
'Content-Transfer-Encoding: 7bit' . CC_FB_SENDMAIL_EOL;

// Set up the default owner message
$form_owner_msg =
'Here is the information submitted to ' .
"{$_SERVER['SERVER_NAME']}{$_SERVER['PHP_SELF']} from " .
"{$_SERVER['REMOTE_ADDR']} on " . date("l, F dS, Y \a\\t g:i a") .
"." . CC_FB_SENDMAIL_EOL . "------------------------" .
CC_FB_SENDMAIL_EOL . "$email_response$unreg" .
CC_FB_SENDMAIL_EOL. CC_FB_SENDMAIL_EOL;

// Add the uploaded file as an attachment if the user has
// request we do so
if(CC_FB_ATTACHMENT_ADDTOEMAIL && $_POST['Uploaded_File'] != '')
{
if(!($contents =
file_get_contents(CC_FB_UPLOADS_DIRECTORY .
"/{$_POST['Uploaded_File']}")))
{
printMessage('Unable To Open Attachment File',"We're sorry but " .
'we were unable to open your uploaded file to attatch it for ' .
'email. Please be sure that you have the proper permissions.');
}

$attachment = chunk_split(base64_encode($contents));

// Setup the unique mime boundary
$mime_boundary = md5(time());

// Set up the form owner mail headers
$form_owner_headers = 'MIME-Version: 1.0' . CC_FB_SENDMAIL_EOL .
'Content-Type: multipart/mixed; ' .
"boundary=\"$mime_boundary\"" .
CC_FB_SENDMAIL_EOL. CC_FB_SENDMAIL_EOL;

// Set up the new form owner message
$form_owner_msg =
"--$mime_boundary" . CC_FB_SENDMAIL_EOL .
'Content-Type: text/plain; charset=utf-8' . CC_FB_SENDMAIL_EOL .
'Content-Transfer-Encoding: 7bit' .
CC_FB_SENDMAIL_EOL. CC_FB_SENDMAIL_EOL .
$form_owner_msg .
"--$mime_boundary" . CC_FB_SENDMAIL_EOL .
'Content-Type: application/octet-stream ' .
"name=\"{$_POST['Uploaded_File']}\"" . CC_FB_SENDMAIL_EOL .
"Content-Transfer-Encoding: base64" . CC_FB_SENDMAIL_EOL .
"Content-Description: {$_POST['Uploaded_File']}" .
CC_FB_SENDMAIL_EOL .
"Content-Disposition: attachment; " .
"filename=\"{$_POST['Uploaded_File']}\"" .
CC_FB_SENDMAIL_EOL . CC_FB_SENDMAIL_EOL .
"$attachment" . CC_FB_SENDMAIL_EOL. CC_FB_SENDMAIL_EOL;
"--$mime_boundary--" .
CC_FB_SENDMAIL_EOL . CC_FB_SENDMAIL_EOL;
}
else
{
$form_owner_headers = $headers;
}

// If we collected the end-user's email
if($_POST['eM'])
{
// Send a message to the form's owner with the end-user's email
// as the reply-to address.
if(CC_FB_DO_EMAIL && !(mail($mail_to,$subject,
$form_owner_msg,
"Reply-To: {$_POST['eM']}" . CC_FB_SENDMAIL_EOL .
"Return-Path: {$_POST['eM']}" . CC_FB_SENDMAIL_EOL .
"From: {$_POST['eM']}" . CC_FB_SENDMAIL_EOL .
"$cc$bcc" .
'Message-ID: <' . time() . "-{$_POST['eM']}>" . CC_FB_SENDMAIL_EOL .
'X-Mailer: PHP v' . phpversion() . CC_FB_SENDMAIL_EOL .
$form_owner_headers)))
{
printMessage('Unable To Send E-Mail',
"We're sorry but we were unable to send your e-mail. " .
'If you are sure that you entered all your email ' .
'addresses properly, you should contact your server ' .
'administrator.');
}

// If necesarry, send a message to the end-user as well.
if(CC_FB_AUTO_REPLY)
{
$auto_reply_msg = '';

if(CC_FB_AUTO_REPLY_FORM_RESULTS)
{
$form_user_msg = $email_response;

if(CC_FB_AUTO_REPLY_POSITION == 'top')
{
$form_user_msg = $auto_reply_msg .
CC_FB_SENDMAIL_EOL . CC_FB_SENDMAIL_EOL .
$form_user_msg;
}
else
{
$form_user_msg .= $auto_reply_msg .
CC_FB_SENDMAIL_EOL . CC_FB_SENDMAIL_EOL;
}
}
else
{
$form_user_msg = $auto_reply_msg;
}

mail($_POST['eM'],CC_FB_AUTO_REPLY_SUBJECT,
"$form_user_msg$unreg",
"Reply-To: $mail_to" . CC_FB_SENDMAIL_EOL .
"Return-Path: $mail_to" . CC_FB_SENDMAIL_EOL .
"From: $mail_to" . CC_FB_SENDMAIL_EOL .
'Message-ID: <' . time() . "-$mail_to>" .
CC_FB_SENDMAIL_EOL .
'X-Mailer: PHP v' . phpversion() . CC_FB_SENDMAIL_EOL .
$headers);
}
}
// Send a message to the form's owner.
elseif(CC_FB_DO_EMAIL && !(mail($mail_to,$subject,
$form_owner_msg,
'From: CoffeeCup Flash Form Builder ' .
"<[email protected]{$_SERVER['SERVER_NAME']}>" . CC_FB_SENDMAIL_EOL .
"$cc$bcc" .
'Message-ID: <' . time() .
"[email protected]{$_SERVER['SERVER_NAME']}>" . CC_FB_SENDMAIL_EOL .
'X-Mailer: PHP v' . phpversion() . CC_FB_SENDMAIL_EOL .
$form_owner_headers)))
{
printMessage('Unable To Send E-Mail',
"We're sorry but we were unable to send your e-mail. " .
'If you are sure that you entered all your email ' .
'addresses properly, you should contact your server ' .
'administrator.');
}
}


/**
* Gets the real name of the file that was uploaded.
*
* Since the file upload occurs in a different request,
* this method helps us resolve what the name of the
* uploaded file was in case it was renamed.
*/
function fixUploadedFileName()
{
if($_POST['Uploaded_File'] != '')
{
$extension = substr($_POST['Uploaded_File'],
strrpos($_POST['Uploaded_File'], '.'));
$basename = basename($_POST['Uploaded_File'], $extension);

while(file_exists(CC_FB_UPLOADS_DIRECTORY . "/$basename".
CC_FB_UPLOADS_EXTENSION . "$i$extension"))
{
$new_upload_name = "$basename". CC_FB_UPLOADS_EXTENSION .
"$i$extension";
$i++;
}

}
$_POST['Uploaded_File'] = $new_upload_name;
}


/**
* Write form response to a database.
*
* Writes the form response to the database specified at 'CC_FB_DB_ADDRESS'
* if appropriate. If the database doesn't it exist, the form_results
* table doesn't exist or if the form_results table doesn't comply with
* the structure of the current form then the database will be restructured
* accordingly.
*
* @param array $preferences the CoffeeCup Flash Form Builder Preferences.
*/
function writeResponseToDatabase($preferences)
{
// If the CC_FB_DB_ADDRESS constant has been populated, then
// the user wants to write their data to a database.
if(CC_FB_DB_ADDRESS != '[ADDRESS]')
{
// First and foremost, lets make sure they have the mysql extension
// loaded.
if(!extension_loaded('mysql'))
{
printMessage('Unable to use MySQL',
"We're sorry but you must have the MySQL extensions loaded " .
'in your PHP configuration in order to save your form '.
'results to a MySQL database. Please contact your ' .
'server administrator.');
}
// Secondly, lets make sure we can connect to their database.
elseif(!($link =
mysql_connect(CC_FB_DB_ADDRESS . ':' . CC_FB_DB_PORT,
CC_FB_DB_USERNAME, CC_FB_DB_PASSWORD)))
{
printMessage('Unable to Connect to Database Server.',
"We're sorry but we were unable to connect to your database " .
'server. Please be sure you have entered your database ' .
'settings correctly.');
}
// If we can't select their DB, lets try to create our own.
elseif(!mysql_select_db(CC_FB_DB_NAME, $link))
{
if(!mysql_query('CREATE DATABASE ' . CC_FB_DB_NAME, $link))
{
printMessage('Unable to Create Database.',
"We're sorry but we were unable to create your database. " .
'If you believe the database already exists, please ' .
'be sure that you have the proper permissions to ' .
'select it. Otherwise, please be sure that you ' .
'have permissions to create databases. If you ' .
'are still experiencing troubles, please contact ' .
'your server administrator.');
}
elseif(!mysql_select_db(CC_FB_DB_NAME, $link))
{
printMessage('Unable to select Database.',
"We're sorry but we were unable to select your database. " .
'Please be sure that you have the proper permissions to ' .
'select it. If you are still experiencing trouble, ' .
'please contact your server administrator.');
}
}

// If a form_results table exists, make sure it is in the
// proper format.
if(mysql_num_rows(mysql_query("SHOW TABLES LIKE 'form_results'",
$link)) != 0)
{
if(!($results = mysql_query('SHOW COLUMNS FROM `form_results`',
$link)))
{
printMessage('Unable to Query Database.',
"We're sorry but we were unable to query your database " .
'table. Please be sure that you have the proper ' .
'permissions to select from the form_results ' .
'table. If you are still experiencing trouble, ' .
'please contact your server administrator.');
}

while($row = mysql_fetch_assoc($results))
{
if($row['Field'] != 'id' && $row['Field'] != 'created_at')
{
$columns[$row['Field']] = $row;
}
}

if(!formFieldsEqualsTableFields($preferences['form_fields'],
$columns))
{
archiveOldTable($link);
createTableFromFormFields($preferences['form_fields'], $link);
}
}
// Otherwise create the form_results table in the proper format.
else
{
createTableFromFormFields($preferences['form_fields'], $link);
}

// If all went well, lets attempt to write the form results to
// the database.
foreach($preferences['form_fields'] as $field_name => $field)
{
$query .= "`$field_name` = " .
mysqlEscape($_POST[$field_name], $link) . ',';
}

// Add the uploaded file to the query if necessary
if(CC_FB_ATTACHMENT_SAVETODB)
{
if($_POST['Uploaded_File'] != '')
{
if(!($contents =
file_get_contents(CC_FB_UPLOADS_DIRECTORY .
"/{$_POST['Uploaded_File']}")))
{
printMessage('Unable To Open Attachment File',"We're sorry " .
'but we were unable to open your uploaded file to ' .
'attach it for email. Please be sure that you have the ' .
'proper permissions.');
}

$query .= '`uploaded_file_name` = ' .
mysqlEscape($_POST['Uploaded_File'], $link) . ',' .
'`uploaded_file` = ' . mysqlEscape($contents, $link) .
',';
}
else
{
$query .= "`uploaded_file_name` = '',`uploaded_file` = '',";
}
}

if(!mysql_query('INSERT INTO `form_results` SET ' .
$query . "`created_at` = NOW()", $link))
{
printMessage('Unable to Insert Into Database Table.',
"We're sorry but we were unable to insert the form results " .
'into your database table. Please be sure that you have ' .
'the proper permissions to insert data into the ' .
'form_results table. If you are still experiencing ' .
'trouble, please contact your server administrator.');
}
}
}


/**
* Archives an old `form_results` table.
*
* Renames a form results table to form_results_old or
* form_results_old with a numerical value on the end of it
* if appropriate.
*
* @param resource $link a database resource
*/
function archiveOldTable($link)
{
while(mysql_num_rows(mysql_query("SHOW TABLES LIKE 'form_results_old$i'",
$link)) != 0)
{
$i++;
}

if(!(mysql_query("RENAME TABLE `form_results` TO `form_results_old$i`",
$link)))
{
printMessage('Unable to Rename Database Table.',
"We're sorry but we were unable to rename your database " .
'table. Please be sure that you have the proper ' .
'permissions to rename the form_results table. If you ' .
'are still experiencing trouble, please contact your ' .
'server administrator.');
}
}


/**
* Escapes a value for MySQL.
*
* Prepares a value to be used safely in a MySQL query. If the value is
* numeric, it is returned. If the value is a string, it is quoted and
* escaped using the mysql_real_escape_string function.
*
* @param mixed $value the value to be escaped
* @param resource $link a database resource
* @return mixed $value the escaped value
*/
function mysqlEscape($value, $link)
{
return ("'" . mysql_real_escape_string($value, $link) . "'");
}


/**
* Checks if the columns from a table match the the structure
* of the fields from a form.
*
* @param array $form_fields the structure from the form
* @param array $table_fields the structure from the table
* @return boolean $value, true if the structures are the same,
* false if the structures are not.
*/
function formFieldsEqualsTableFields($form_fields, $table_fields)
{
// Make sure we have the proper fields for saving uploaded
// files to the database if the user has requested we do so
if(CC_FB_ATTACHMENT_SAVETODB)
{
if(array_key_exists('uploaded_file', $table_fields) &&
array_key_exists('uploaded_file_name', $table_fields))
{
unset($table_fields['uploaded_file_name']);
unset($table_fields['uploaded_file']);
}
else
{
return false;
}
}

if(count($form_fields) != count($table_fields))
{
return false;
}

foreach($form_fields as $field_name => $field)
{
if(!is_array($table_fields[$field_name]) ||
!(($field['type'] == 'textarea' &&
$table_fields[$field_name]['Type'] == 'text') ||
$table_fields&#

This post has been edited by no2pencil: 26 April 2008 - 06:58 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Hosting Company php5 issue

#2 Martyr2   User is offline

  • Programming Theoretician
  • member icon

Reputation: 5552
  • View blog
  • Posts: 14,558
  • Joined: 18-April 07

Re: Hosting Company php5 issue

Posted 26 April 2008 - 11:56 AM

There are three places I identified that you would need to change to add in this extra 5th parameter. Below I have posted five pieces of code that you must identify in the code you posted (They are all about half way through the script and are one right after the other) and add in an extra line I have identified in red.

Segment 1...
// If we collected the end-user's email
if($_POST['eM'])
{
// Send a message to the form's owner with the end-user's email
// as the reply-to address.
if(CC_FB_DO_EMAIL && !(mail($mail_to,$subject,
$form_owner_msg,
"Reply-To: {$_POST['eM']}" . CC_FB_SENDMAIL_EOL .
"Return-Path: {$_POST['eM']}" . CC_FB_SENDMAIL_EOL .
"From: {$_POST['eM']}" . CC_FB_SENDMAIL_EOL .
"$cc$bcc" .
'Message-ID: <' . time() . "-{$_POST['eM']}>" . CC_FB_SENDMAIL_EOL .
'X-Mailer: PHP v' . phpversion() . CC_FB_SENDMAIL_EOL .
$form_owner_headers[color=#FF0000], "-f$mail_to"[/color])))
{
printMessage('Unable To Send E-Mail',
"We're sorry but we were unable to send your e-mail. " .
'If you are sure that you entered all your email ' .
'addresses properly, you should contact your server ' .
'administrator.');
}



Segment 2...

mail($_POST['eM'],CC_FB_AUTO_REPLY_SUBJECT,
"$form_user_msg$unreg",
"Reply-To: $mail_to" . CC_FB_SENDMAIL_EOL .
"Return-Path: $mail_to" . CC_FB_SENDMAIL_EOL .
"From: $mail_to" . CC_FB_SENDMAIL_EOL .
'Message-ID: <' . time() . "-$mail_to>" .
CC_FB_SENDMAIL_EOL .
'X-Mailer: PHP v' . phpversion() . CC_FB_SENDMAIL_EOL .
$headers[color=#FF0000], "-f$mail_to"[/color]);



Segment 3...

// Send a message to the form's owner.
elseif(CC_FB_DO_EMAIL && !(mail($mail_to,$subject,
$form_owner_msg,
'From: CoffeeCup Flash Form Builder ' .
"<[email protected]{$_SERVER['SERVER_NAME']}>" . CC_FB_SENDMAIL_EOL .
"$cc$bcc" .
'Message-ID: <' . time() .
"[email protected]{$_SERVER['SERVER_NAME']}>" . CC_FB_SENDMAIL_EOL .
'X-Mailer: PHP v' . phpversion() . CC_FB_SENDMAIL_EOL .
$form_owner_headers[color=#FF0000], "-f$mail_to"[/color])))
{
printMessage('Unable To Send E-Mail',
"We're sorry but we were unable to send your e-mail. " .
'If you are sure that you entered all your email ' .
'addresses properly, you should contact your server ' .
'administrator.'); 



Now essentially what I have done here is tracked down everywhere in that script that uses the mail function and added the 5th parameter which, according to the ISP, needs to consist of the -f switch followed by the email address of the sender. In this case it appears the sender is located in the $mail_to variable.

So in theory this should work for you if the email address in $mail_to is an actual working email address... which should be since you said you have sent mail before with this until they upgraded.

So give it a shot and see what happens. Make sure you have clearly identified these areas and made only the changes I have shown above. You might have to come back to these sections if this fix doesn't work.

If it doesn't work, be sure to report any error messages you receive. Thanks for helping me help you. :)
Was This Post Helpful? 0
  • +
  • -

#3 philb   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 26-April 08

Re: Hosting Company php5 issue

Posted 26 April 2008 - 12:32 PM

Hi Martyr2

Thank you very much for your reply. I have put in these parameters but still no luck. The form seems to submit, but no data is collected in the webmail account. Its a real pain to say the least. Any other ideas appriciated.
Thanks

Phil





View PostMartyr2, on 26 Apr, 2008 - 11:56 AM, said:

There are three places I identified that you would need to change to add in this extra 5th parameter. Below I have posted five pieces of code that you must identify in the code you posted (They are all about half way through the script and are one right after the other) and add in an extra line I have identified in red.

Segment 1...

// If we collected the end-user's email
if($_POST['eM'])
{
// Send a message to the form's owner with the end-user's email
// as the reply-to address.
if(CC_FB_DO_EMAIL && !(mail($mail_to,$subject,
$form_owner_msg,
"Reply-To: {$_POST['eM']}" . CC_FB_SENDMAIL_EOL .
"Return-Path: {$_POST['eM']}" . CC_FB_SENDMAIL_EOL .
"From: {$_POST['eM']}" . CC_FB_SENDMAIL_EOL .
"$cc$bcc" .
'Message-ID: <' . time() . "-{$_POST['eM']}>" . CC_FB_SENDMAIL_EOL .
'X-Mailer: PHP v' . phpversion() . CC_FB_SENDMAIL_EOL .
$form_owner_headers, "-f$mail_to")))
{
printMessage('Unable To Send E-Mail',
"We're sorry but we were unable to send your e-mail. " .
'If you are sure that you entered all your email ' .
'addresses properly, you should contact your server ' .
'administrator.');
}


Segment 2...


mail($_POST['eM'],CC_FB_AUTO_REPLY_SUBJECT,
"$form_user_msg$unreg",
"Reply-To: $mail_to" . CC_FB_SENDMAIL_EOL .
"Return-Path: $mail_to" . CC_FB_SENDMAIL_EOL .
"From: $mail_to" . CC_FB_SENDMAIL_EOL .
'Message-ID: <' . time() . "-$mail_to>" .
CC_FB_SENDMAIL_EOL .
'X-Mailer: PHP v' . phpversion() . CC_FB_SENDMAIL_EOL .
$headers, "-f$mail_to");


Segment 3...

// Send a message to the form's owner.
elseif(CC_FB_DO_EMAIL && !(mail($mail_to,$subject,
$form_owner_msg,
'From: CoffeeCup Flash Form Builder ' .
"<[email protected]{$_SERVER['SERVER_NAME']}>" . CC_FB_SENDMAIL_EOL .
"$cc$bcc" .
'Message-ID: <' . time() .
"[email protected]{$_SERVER['SERVER_NAME']}>" . CC_FB_SENDMAIL_EOL .
'X-Mailer: PHP v' . phpversion() . CC_FB_SENDMAIL_EOL .
$form_owner_headers, "-f$mail_to")))
{
printMessage('Unable To Send E-Mail',
"We're sorry but we were unable to send your e-mail. " .
'If you are sure that you entered all your email ' .
'addresses properly, you should contact your server ' .
'administrator.');

Now essentially what I have done here is tracked down everywhere in that script that uses the mail function and added the 5th parameter which, according to the ISP, needs to consist of the -f switch followed by the email address of the sender. In this case it appears the sender is located in the $mail_to variable.

So in theory this should work for you if the email address in $mail_to is an actual working email address... which should be since you said you have sent mail before with this until they upgraded.

So give it a shot and see what happens. Make sure you have clearly identified these areas and made only the changes I have shown above. You might have to come back to these sections if this fix doesn't work.

If it doesn't work, be sure to report any error messages you receive. Thanks for helping me help you. :)



View Postphilb, on 26 Apr, 2008 - 12:25 PM, said:

Hi Martyr2

Thank you very much for your reply. I have put in these parameters but still no luck. The form seems to submit, but no data is collected in the webmail account. Its a real pain to say the least. Any other ideas appriciated.
Thanks

Phil





View PostMartyr2, on 26 Apr, 2008 - 11:56 AM, said:

There are three places I identified that you would need to change to add in this extra 5th parameter. Below I have posted five pieces of code that you must identify in the code you posted (They are all about half way through the script and are one right after the other) and add in an extra line I have identified in red.

Segment 1...

// If we collected the end-user's email
if($_POST['eM'])
{
// Send a message to the form's owner with the end-user's email
// as the reply-to address.
if(CC_FB_DO_EMAIL && !(mail($mail_to,$subject,
$form_owner_msg,
"Reply-To: {$_POST['eM']}" . CC_FB_SENDMAIL_EOL .
"Return-Path: {$_POST['eM']}" . CC_FB_SENDMAIL_EOL .
"From: {$_POST['eM']}" . CC_FB_SENDMAIL_EOL .
"$cc$bcc" .
'Message-ID: <' . time() . "-{$_POST['eM']}>" . CC_FB_SENDMAIL_EOL .
'X-Mailer: PHP v' . phpversion() . CC_FB_SENDMAIL_EOL .
$form_owner_headers, "-f$mail_to")))
{
printMessage('Unable To Send E-Mail',
"We're sorry but we were unable to send your e-mail. " .
'If you are sure that you entered all your email ' .
'addresses properly, you should contact your server ' .
'administrator.');
}


Segment 2...


mail($_POST['eM'],CC_FB_AUTO_REPLY_SUBJECT,
"$form_user_msg$unreg",
"Reply-To: $mail_to" . CC_FB_SENDMAIL_EOL .
"Return-Path: $mail_to" . CC_FB_SENDMAIL_EOL .
"From: $mail_to" . CC_FB_SENDMAIL_EOL .
'Message-ID: <' . time() . "-$mail_to>" .
CC_FB_SENDMAIL_EOL .
'X-Mailer: PHP v' . phpversion() . CC_FB_SENDMAIL_EOL .
$headers, "-f$mail_to");


Segment 3...

// Send a message to the form's owner.
elseif(CC_FB_DO_EMAIL && !(mail($mail_to,$subject,
$form_owner_msg,
'From: CoffeeCup Flash Form Builder ' .
"<[email protected]{$_SERVER['SERVER_NAME']}>" . CC_FB_SENDMAIL_EOL .
"$cc$bcc" .
'Message-ID: <' . time() .
"[email protected]{$_SERVER['SERVER_NAME']}>" . CC_FB_SENDMAIL_EOL .
'X-Mailer: PHP v' . phpversion() . CC_FB_SENDMAIL_EOL .
$form_owner_headers, "-f$mail_to")))
{
printMessage('Unable To Send E-Mail',
"We're sorry but we were unable to send your e-mail. " .
'If you are sure that you entered all your email ' .
'addresses properly, you should contact your server ' .
'administrator.');

Now essentially what I have done here is tracked down everywhere in that script that uses the mail function and added the 5th parameter which, according to the ISP, needs to consist of the -f switch followed by the email address of the sender. In this case it appears the sender is located in the $mail_to variable.

So in theory this should work for you if the email address in $mail_to is an actual working email address... which should be since you said you have sent mail before with this until they upgraded.

So give it a shot and see what happens. Make sure you have clearly identified these areas and made only the changes I have shown above. You might have to come back to these sections if this fix doesn't work.

If it doesn't work, be sure to report any error messages you receive. Thanks for helping me help you. :)



Hi Martyr2

Just to let you know, this script works on the site:
form method="post" action="sendmail.php">
Email: <input name="email" type="text" style="width: 285px" /><br />
Message:<br />
<textarea name="message" style="width: 335px; height: 90px">
</textarea><br />
<input type="submit" /> 
</form



** Save as sendmail.php ***

<?php

mail("[email protected]", "Feedback Form results", $_REQUEST[message], "From: $_REQUEST[email]", "-f".$_REQUEST[email]);

header( "Location: [url=http://www.yourdomain.co.uk/thankyou.html"]http://www.yourdomain.co.uk/thankyou.html"[/url] );

?>


Was This Post Helpful? 0
  • +
  • -

#4 Martyr2   User is offline

  • Programming Theoretician
  • member icon

Reputation: 5552
  • View blog
  • Posts: 14,558
  • Joined: 18-April 07

Re: Hosting Company php5 issue

Posted 26 April 2008 - 12:36 PM

What it with the replies, you keep quoting repeated stuff.

Do you have a separate copy of this script for each client site?
Was This Post Helpful? 0
  • +
  • -

#5 philb   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 26-April 08

Re: Hosting Company php5 issue

Posted 26 April 2008 - 12:46 PM

Yeh its fixed well done Martyr2 you are such a star. There must have been a conflict with using root as now when I use anything before the @ sign its working fine. Thank you so much I appriciate this more than you can ever imagine.

Cheers
Phil
Was This Post Helpful? 0
  • +
  • -

#6 Martyr2   User is offline

  • Programming Theoretician
  • member icon

Reputation: 5552
  • View blog
  • Posts: 14,558
  • Joined: 18-April 07

Re: Hosting Company php5 issue

Posted 26 April 2008 - 12:47 PM

Fabulous. Thanks for stopping by.

This ghetto supersta is out! :D
Was This Post Helpful? 0
  • +
  • -

#7 tamgoose   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 04-May 08

Re: Hosting Company php5 issue

Posted 04 May 2008 - 07:40 AM

Hi,

I have the exact same problem and it's driving me insane!!!

I am with streamline.net also and I cannot figure out this 5th parameter stuff.

Basically I have a CMS site - When people register to the site THEY don't receive any emails and I dont receive any admin emails either, same with all my forums etc. The forms say they are working but Im not receiving any email from any forms on any of my sites.

If someone could please fix this code so I can copy and paste it into all my sites so they all work - I would be super delighted!!!!

Kindest Regards,
Faser

[code]<?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
*/
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 = "utf-8";

/**
* 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 = "[email protected]";

/**
* 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 = "[email protected]";

/**
* 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").
* @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.73";

/**
* 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 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;
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 != "") {
$this->Sender = escapeshellcmd($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 = '[email protected]';
$rt = @mail("[email protected]", $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 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 . "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;
}

/**
* 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_attachments":
$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: <%[email protected]%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]),
 &nbs
Was This Post Helpful? 0
  • +
  • -

#8 Martyr2   User is offline

  • Programming Theoretician
  • member icon

Reputation: 5552
  • View blog
  • Posts: 14,558
  • Joined: 18-April 07

Re: Hosting Company php5 issue

Posted 04 May 2008 - 09:44 AM

Locate anywhere it is using the "mail()" function and make sure you pass along a fifth parameter which is additional parameters. sendmail is essentially a program that can be run from a command prompt. So you can pass it additional parameters which tell it how to do its job. Apparently streamline.net is requiring everyone to specify the -f switch and the address of where the mail is coming from.

So to make a long story short, in your scripts locate everywhere you are using the mail() function and make sure you are passing five parameters to it, the last one being '[email protected]' format of the sender of the email.

So if my script was sending mail on my behalf from my address it would be like...

mail($to, $from, $message, $headers, '[email protected]');



Notice how the fifth parameter is my username and a hostname for which the system sends mail from my address if I was running it on dreamincode.net. Make sure that the username and hostname is a valid email account from the host you are sending from (your site domain).

Good luck. :)

This post has been edited by Martyr2: 04 May 2008 - 09:45 AM

Was This Post Helpful? 0
  • +
  • -

#9 mikerg   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 4
  • Joined: 05-May 08

Re: Hosting Company php5 issue

Posted 05 May 2008 - 02:05 AM

Hello everyone.
I'm new here, just registered with the forum to document my appreciation for the solution posted here.
:)


View PostMartyr2, on 4 May, 2008 - 09:44 AM, said:

Locate anywhere it is using the "mail()" function and make sure you pass along a fifth parameter which is additional parameters. sendmail is essentially a program that can be run from a command prompt. So you can pass it additional parameters which tell it how to do its job. Apparently streamline.net is requiring everyone to specify the -f switch and the address of where the mail is coming from.

So to make a long story short, in your scripts locate everywhere you are using the mail() function and make sure you are passing five parameters to it, the last one being '[email protected]' format of the sender of the email.

So if my script was sending mail on my behalf from my address it would be like...

mail($to, $from, $message, $headers, '[email protected]');



Notice how the fifth parameter is my username and a hostname for which the system sends mail from my address if I was running it on dreamincode.net. Make sure that the username and hostname is a valid email account from the host you are sending from (your site domain).

Good luck. :)


I also use Streamline.net for hosting and have been looking for a resolution to this 5th parameter problem for a couple of weeks.

This solution has explained it fully and I am VERY gratefull for the information.
Being new to PHP, I didn't realise that the -F was a command line switch

My problem was that I use Bcc to monitor enquiries from my clients sites. But after adding the -F switch, I had no room left for the Bcc parameter.
Having seen your solution ;
mail($to, $from, $message, $headers, '[email protected]');


It became obvious to place the Bcc in a headers variable and the -f switch after it. (It doesn't work the other way round, ie; '[email protected]', $headers.

I am all back up and running thanks to your info and am going to suggest to streamline that this info is offered in their FAQ pages.

:^: THANKYOU VERY MUCH Martyr2 :^:
Was This Post Helpful? 0
  • +
  • -

#10 firstsagba   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 12-May 08

Re: Hosting Company php5 issue

Posted 12 May 2008 - 12:36 PM

Hello Everyone,

My first time, absolutely new to PHP code and the forum. FANTASTIC.

The documentation was spot on the first time. Bless You Martyr2

Cheers :^:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1