Forums

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

Home Forums Back End Php form mailer (Adding a file attachment)

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #33001
    bentalgad
    Participant

    Hi! I have a working and simple php mailer that i love, but it’s only missing one thing: The upload file attachment.

    This is my form’s code:

     




































    ‪<‬span class="movieMessege"‪>‬
    *אפשר לצרף גם כתובת סרטון YouTube לתיבת התוכן והסרט יופיע בתוך העמוד.





















    And this is my php mailer’s code:

    
    
    $SendFrom = "[email protected]";
    $SendTo = "[email protected]";
    $SubjectLine = "מורה גיטרה חדש";
    $ThanksURL = "http://www.guitara.co.il/%D7%94%D7%98%D7%95%D7%A4%D7%A1-%D7%A0%D7%A9%D7%9C%D7%97-%D7%91%D7%94%D7%A6%D7%9C%D7%97%D7%94/";

    // Build Message Body from Web Form Input
    foreach ($_POST as $Field=>$Value)
    $MsgBody .= "$Field: $Valuen";

    $MsgBody = htmlspecialchars($MsgBody, ENT_NOQUOTES); //make safe

    // Send E-Mail and Direct Browser to Confirmation Page
    mail($SendTo, $SubjectLine, $MsgBody, "From: $SendFrom");
    header("Location: $ThanksURL");

    ?>

    I would be very happy if one could help me add the code needed
    for that php mailer to attach the file to that mail he is sending.

    ThankYouAnyWay!!!

    #74145
    TT_Mark
    Member

    This is something I’m just about to do for a recruitment website…although I have no idea where to start!

    Your form is missing an enctype attribute though

    #74134
    ddliu
    Member

    Here is an example how to include an attchment with mail function:
    http://www.webcheatsheet.com/PHP/send_email_text_html_attachment.php#attachment

    You may try a mail library instead of built in PHP function, if you need more features and want to go more comfortable. I’d like to recommend you Swiftmailer if you want to have a try.

    #74109
    bentalgad
    Participant

    Thank’s TT_mark & ddliu,

    But I need something that I can just add on my current simple php code,
    and I don’t need an enctype attribute for it.

    #74055
    TT_Mark
    Member

    You have to have an enctype attribute to upload the file :-)

    #73936
    bentalgad
    Participant

    Oh, thank’s, I didn’t know that.

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