Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End problem sending an attachment to email via php

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #36411
    drizzy
    Participant

    Hey everyone,
    I’m pretty new to this php stuff, but I’m trying to create a page that the user uploads there resume and that gets sent to my email account. Right now it says its been sent, but I don’t see it in my inbox at all. I don’t know what I’m doing wrong

    Can anyone look at the code and tell me what I’m doing wrong TIA
    here’s the link

    and my code:

    
    $name    = $_POST;
    $email = $_POST;
    $eligible = $_POST;
    $type = $_POST;

    if(isset($_POST))
    {
    //The form has been submitted, prep a nice thank you message
    $output = "
    ";
    "

    Email Sent Successfully.

    ";
    "

    Thank you $name, your resume has been submitted to us.

    ";
    "
    ";


    //Set the form flag to no display (cheap way!)
    $flags = 'style="display:none;"';

    //Deal with the email
    $to = '[email protected]';
    $subject = 'Magic Bus Company Employment Application Form';

    // $message = strip_tags($_POST);
    $attachment = chunk_split(base64_encode(file_get_contents($_FILES)));
    $filename = $_FILES;

    $boundary =md5(date('r', time()));

    $headers = "From: $emailrnReply-To: $to";
    $headers .= "rnMIME-Version: 1.0rnContent-Type: multipart/mixed; boundary="_1_$boundary"";

    $message="This is a multi-part message in MIME format.
    Name: $name;rnn
    Email: $email;rnn
    Are you eligible to work in Canada? $eligible;rnn
    What type of drivers license do you have? $type;rnn

    --_1_$boundary
    Content-Type: multipart/alternative; boundary="_2_$boundary"

    --_2_$boundary
    Content-Type: text/plain; charset="iso-8859-1"
    Content-Transfer-Encoding: 7bit

    $message

    --_2_$boundary--
    --_1_$boundary
    Content-Type: application/octet-stream; name="$filename"
    Content-Transfer-Encoding: base64
    Content-Disposition: attachment

    $attachment
    --_1_$boundary--";

    mail($to, $subject, $message, $headers);
    }
    ?>




    MailFile







    >

































    #95851
    bungle
    Member

    I would put a condition on the mail() function and see what it returns.

    I think your error/success messages should really be moved down the code so they are dependent on the mail function succeeding rather than just the posting of the form itself.

    if (mail($to, $subject, $body, $headers)) {
    echo(“Thank you for your submission.”);
    }
    else {
    echo(“We’re sorry, but there was an error processing your request.”);
    }

    This should point you as to whether your PHP system is actually sending the mail at all. I have had problems with the basic mail() function on certain ISP.

    #95934
    drizzy
    Participant

    Thank a lot I’ll give it a try and let you know :)

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘Back End’ is closed to new topics and replies.