Grow your CSS skills. Land your dream job.

PHP Email Problems…

  • # March 19, 2012 at 11:16 pm

    OK, so…I am currently working on an email form for a client who wants to use the following encryption to encrypt emails sent from his site ( please don’t ask me why, I haven’t the slightest idea why lol)…


    < ?php
    function encode($thetext)
    {
    $iv = "51901410686694700275125677623053";
    $key = "super secret encryption key";
    $text = $thetext;
    $block = mcrypt_get_block_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC);
    $padding = $block - (strlen($text) % $block);
    $text .= str_repeat(chr($padding), $padding);
    $crypttext = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $text, MCRYPT_MODE_CBC, $iv);
    $encodedMsg = base64_encode($crypttext);
    return ($encodedMsg) . "n
    ";
    }
    ?>

    My Problem is, I cannot figure out how to get the encode() function to parse the posted data and properly display in the email sent from the server…Here is my email script as is stripped as much as possible


    < ?php
    $recipient = "email@email.com";
    $subject = "Super Secret Encrypted Message";
    $name = encode($_REQUEST);
    $contactPref = encode($_REQUEST);
    $email = encode($_REQUEST);
    $phone = encode($_REQUEST);
    $state = encode($_REQUEST);
    $county = encode($_REQUEST);
    $primary = encode($_REQUEST);
    $clinic = encode($_REQUEST);
    $docCity = encode($_REQUEST);
    $inquiry = encode($_REQUEST);

    $emailBody .= "Name: " . $name;
    $emailBody .= "Contact Preference: " . $contactPref;
    $emailBody .= "Email: " . $email;
    $emailBody .= "Phone: " . $phone;
    $emailBody .= "State: " . $state;
    $emailBody .= "County: " . $county;
    $emailBody .= "Primary Care: " . $primary;
    $emailBody .= "Clinic Name: " . $clinic;
    $emailBody .= "Physician's City: " . $docCity;
    $emailBody .= "Questions/Comments: " . $inquiry;

    mail($recipient, $subject, $emailBody, "From: $email");

    ?>

    And Of course, that doesn’t work…It shoots me a 500 error :(

    If anyone has any suggestions i would more than appreciate it!

    Thanks guys…The solution is simple and on the tip of my tongue but i just can’t get it out.

    p.s. I removed all validation and comments to make it really really minimal…

    # March 20, 2012 at 12:40 am

    I think this

    $email = encode($_REQUEST);

    might be causing problems for this

    mail($recipient, $subject, $emailBody, "From: $email");
    # March 20, 2012 at 12:50 am

    Funny you say that, because I already thought that would be an issue and passed $_REQUEST through the email validation function like this…

    if ( isValidEmail($_REQUEST) )

    But I coompletely overlooked the actual mail() function itself…

    I will give that a go and see what happens…Thanks a lot for noticing that!

    # March 20, 2012 at 1:09 am

    Nevermind, figured out the issue, did a phpinfo() on the server…turns out mcrypt is not installed…i was told it was…guess i should have double checked anyhow.

    # March 20, 2012 at 1:10 am

    ha good old phpinfo :D

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".