-3

here is the problem, couldn't find much googling, hope somebody here got the answer for this. My PHP file is sending emails as feedback to me, and it takes 5 arguments, whenever I send long arguments to my PHP file, it trims the end of argument 5, which is the longest one, how can I fix that? To be more clear argument 5 is pretty much the email body.

Here is the PHP code:

<?php
include('Mail.php');
$arg1 = $argv[1]; //appName and version
$arg2 = $argv[2]; //ErrorMessage
$arg3 = $argv[3]; //ErrorData
$arg4 = $argv[4]; //ErrorSource
$arg5 = $argv[5]; //ErrorStackTrace
$arg1 = $_GET['arg1'];
$arg2 = $_GET['arg2'];
$arg3 = $_GET['arg3'];
$arg4 = $_GET['arg4'];
$arg5 = $_GET['arg5'];

$subject = $arg1 ;
$errorMessage = $arg2;
$ErrorData = $arg3;
$ErrorSource = $arg4;
$ErrorStackTrace = $arg5;

$recipients = "myemail";
$from = "errorreport@user.com" ;

$headers = array (
    'From' => $from,
    'To' => $recipients,
    'Subject' => $subject,
);
$body = "ErrorMessage: "."\n".$errorMessage."\n"."ErrorData: "."\n".$ErrorData."\n"."ErrorSource: "."\n".$ErrorSource."\n"."ErrorStackTrace: "."\n".$ErrorStackTrace;

$mail_object =& Mail::factory('smtp',
    array(
        'host' => 'prwebmail',
        'auth' => true,
        'username' => 'user',
        'password' => 'pass',       ));
$mail_object->send($recipients, $headers, $body);

?>
Johnny
  • 95
  • 2
  • 8
  • 3
    Post some code, it sounds like you have a
    and your webserver or browser is truncating the data. a
    might be the simple solution, but we need code examples. http://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers
    – Scuzzy Mar 13 '14 at 02:22
  • I also noticed the first lines of your code `$arg1 = $argv[1];` will be overwritten by `$arg1 = $_GET['arg1'];` – Scuzzy Mar 13 '14 at 02:33
  • sorry, new to PHP, should I remove them? – Johnny Mar 13 '14 at 02:34
  • found the problem, my argument included "&" had to encode it. – Johnny Mar 13 '14 at 02:51

1 Answers1

1

I can see your code is referencing $_GET variables, please change your form to use a method of POST

If you are able to, shy away from GET method forms when sending large data.

find:

<form method="get">

replace with:

<form method="post">

then change:

$arg1 = $_GET['arg1'];

to:

$arg1 = $_POST['arg1'];

etc...

Scuzzy
  • 12,186
  • 1
  • 46
  • 46