• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

issues with PHP:mail()

Fullmetal Chocobo

Moderator<br>Distributed Computing
Moderator
I can't figure out why the below script would work using $link2 but not $link2 (in place of $link1 in the script). I thought it might be something regarding escape characters, but none of them are being escaped when I echo them out. In fact, it works fine with the address ip of 5.5.5, but not when I put another octet on it. I thought it might be due to length (over 70 characters), but that didn't affect it either.

I'm digging through PHP, Apache, and Ubuntu books now, as the environment is a LAMP setup. Anyone have any idea?

PHP:
function mail_request( $whom )
{
   # email 'to' address passed into function
   $to = $whom;  

   $link1 = "https://4.4.4.4/dev/forms/p-card/approve.php";
   $link2 = "https://fourfours/dev/forms/p-card/approve.php";

   $name = $_POST['name'];

   $dept = $_POST['dept'];

   $body = $_POST['requestor'];
   $body .= " has requested to purchase the following from ";
   $body .= $_POST['vendor'] . ":";
   $body .= $_POST['description'];
   $body .= "<br /><a href=\"" . $link2 . "\">Approve or Deny here</a><br />";

   $subject = "P-Card Purchase Request Pending Approval";

   $headers  = "MIME-Version: 1.0" . "\r\n";
   $headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n";
   $headers .= "From: William Tom Frank <jemann@somewhere.com>" . "\r\n";
   
   # print components of email for troubleshooting
   #echo "\$to = " . $to . "<br />\n";
   #echo "\$subject = " . $subject . "<br />\n";
   #echo "\$body = " . $body . "<br />\n";
   #echo "\$headers = " . $headers . "<br />\n";

   $result = mail( $to, $subject, $body, $headers );
   
   # echo result from sending email
   echo "\$result = " . $result;
}
 
I can't figure out why the below script would work using $link2 but not $link2 (in place of $link1 in the script). I thought it might be something regarding escape characters, but none of them are being escaped when I echo them out. In fact, it works fine with the address ip of 5.5.5, but not when I put another octet on it. I thought it might be due to length (over 70 characters), but that didn't affect it either.

I'm digging through PHP, Apache, and Ubuntu books now, as the environment is a LAMP setup. Anyone have any idea?

PHP:
function mail_request( $whom )
{
   # email 'to' address passed into function
   $to = $whom;  

   $link1 = "https://4.4.4.4/dev/forms/p-card/approve.php";
   $link2 = "https://fourfours/dev/forms/p-card/approve.php";

   $name = $_POST['name'];

   $dept = $_POST['dept'];

   $body = $_POST['requestor'];
   $body .= " has requested to purchase the following from ";
   $body .= $_POST['vendor'] . ":";
   $body .= $_POST['description'];
   $body .= "<br /><a href=\"" . $link2 . "\">Approve or Deny here</a><br />";

   $subject = "P-Card Purchase Request Pending Approval";

   $headers  = "MIME-Version: 1.0" . "\r\n";
   $headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n";
   $headers .= "From: William Tom Frank <jemann@somewhere.com>" . "\r\n";
   
   # print components of email for troubleshooting
   #echo "\$to = " . $to . "<br />\n";
   #echo "\$subject = " . $subject . "<br />\n";
   #echo "\$body = " . $body . "<br />\n";
   #echo "\$headers = " . $headers . "<br />\n";

   $result = mail( $to, $subject, $body, $headers );
   
   # echo result from sending email
   echo "\$result = " . $result;
}


Add this line right before your function call and post what the error is:

error_reporting(E_ALL);
 
Back
Top