Hey there! Sign in to join this conversationNew here? Join for free
    • Thread Starter
    Offline

    21
    ReputationRep:
    for example

    say on my website a user fills out their email in a field.

    once they click on the submit button, how do i send a file to their email ?

    any ideas UWS IWMTom
    • Very Important Poster
    • Welcome Squad
    Offline

    20
    ReputationRep:
    I believe this will only work if you have a mail client set up via hosting. This does not work if you set up your website locally

    You will need to get the email address and pass it through some PHP. Assuming you have your mail client set up of course.

    Look at the documentation for the mail() function.
    http://php.net/manual/en/function.mail.php

    https://stackoverflow.com/questions/...mail-using-php
    • Thread Starter
    Offline

    21
    ReputationRep:
    (Original post by UWS)
    I believe this will only work if you have a mail client set up via hosting. This does not work if you set up your website locally

    You will need to get the email address and pass it through some PHP. Assuming you have your mail client set up of course.

    Look at the documentation for the mail() function.
    http://php.net/manual/en/function.mail.php

    https://stackoverflow.com/questions/...mail-using-php
    this PHP stuff is completely new to me

    any beginner tutorial ?
    Offline

    5
    ReputationRep:
    You could learn the fundamentals of PHP in a day or two on W3Schools (which I'd favour for).
    • Very Important Poster
    • Welcome Squad
    Offline

    20
    ReputationRep:
    (Original post by study beats)
    this PHP stuff is completely new to me

    any beginner tutorial ?


    As I said though, the mail() function won't work if your website is hosted locally. Unless this is a hard requirement, you probably need to find an alternative to sending users a file.
    • Thread Starter
    Offline

    21
    ReputationRep:
    (Original post by Cholesterol)
    You could learn the fundamentals of PHP in a day or two on W3Schools (which I'd favour for).
    i only wanna send email
    • Thread Starter
    Offline

    21
    ReputationRep:
    (Original post by UWS)


    As I said though, the mail() function won't work if your website is hosted locally. Unless this is a hard requirement, you probably need to find an alternative to sending users a file.
    what do you mean if my website is hosted locally ?

    and what are the alternatives?

    also is there just a php email tutorial?
    • Very Important Poster
    • Welcome Squad
    Offline

    20
    ReputationRep:
    (Original post by study beats)
    what do you mean if my website is hosted locally ?

    and what are the alternatives?

    also is there just a php email tutorial?
    Your PC is the host, I suspect you haven't paid for a live domain right?

    I'm only aware of the mail() function using PHP.

    Look at the stackoverflow link I have given you as well as the documentation.
    • Community Assistant
    Online

    18
    ReputationRep:
    (Original post by study beats)
    for example

    say on my website a user fills out their email in a field.

    once they click on the submit button, how do i send a file to their email ?

    any ideas UWS IWMTom
    As @UWS has said, PHP is your best bet here, as it's already on practically every web hosting server going.

    The mail() function can hook into a remote SMTP server, providing you know the information - this would allow you to send from a GMail address, for example.
    • Thread Starter
    Offline

    21
    ReputationRep:
    (Original post by UWS)
    Your PC is the host, I suspect you haven't paid for a live domain right?

    I'm only aware of the mail() function using PHP.

    Look at the stackoverflow link I have given you as well as the documentation.
    i have a server i can upload my website too
    • Thread Starter
    Offline

    21
    ReputationRep:
    (Original post by IWMTom)
    As @UWS has said, PHP is your best bet here, as it's already on practically every web hosting server going.

    The mail() function can hook into a remote SMTP server, providing you know the information - this would allow you to send from a GMail address, for example.
    is there a simple tutorial i could follow to do this?
    • Community Assistant
    Online

    18
    ReputationRep:
    (Original post by study beats)
    is there a simple tutorial i could follow to do this?
    Read the documentation; it's self explanatory
    Offline

    15
    ReputationRep:
    As everyone has said, PHP is ideal. PHP only works on Linux so you'll need to get webhosting that is a Linux server and runs PHP (pretty much all of them) but it won't work on your home computer. I did a quick google, and here's a code, I've slightly altered it for you, you want to save the file with a .php extension. I've never tried sending an attachment through a PHP mailer though.


    Code:
    <?PHP
    if(!$_POST[send]){
    ?>
    
    <form method="POST">
    Your Email:<input type="email" name="email" class="textbox"><br />
    <input name="send" type="submit" id="send" value="Send">
    </form>
    
    <?PHP
    }else{
    $emailaddress = $_POST[email];
    
    $email = new PHPMailer();
    $email->From = '[email protected]';
    $email->FromName = 'Your Name';
    $email->Subject = 'Message Subject';
    $email->Body = $bodytext;
    $email->AddAddress( '$emailaddress' );
    $file_to_attach = 'PATH_OF_YOUR_FILE_HERE';
    $email->AddAttachment( $file_to_attach , 'NameOfFile.pdf' );
    return $email->Send();
    
    }
    
    ?>

    PS. I've not actually tried this particular script so I don't know how reliable it is, it's just something I've found on Google
    • Community Assistant
    Online

    18
    ReputationRep:
    (Original post by Whispers)
    As everyone has said, PHP is ideal. PHP only works on Linux so you'll need to get webhosting that is a Linux server and runs PHP (pretty much all of them) but it won't work on your home computer. I did a quick google, and here's a code, I've slightly altered it for you, you want to save the file with a .php extension. I've never tried sending an attachment through a PHP mailer though.

    Code:
    <?PHP
    if(!$_POST[send]){
    ?>
    <form method="POST">
    Your Email:<input type="email" name="email" class="textbox"><br />
    <input name="send" type="submit" id="send" value="Send">
    <?PHP 
    }else{
    $emailaddress = $_POST[email]; 
    
    $email = new PHPMailer();
    $email->From      = '[email protected]';
    $email->FromName  = 'Your Name';
    $email->Subject   = 'Message Subject';
    $email->Body      = $bodytext;
    $email->AddAddress( '$emailaddress' );
    $file_to_attach = 'PATH_OF_YOUR_FILE_HERE';
    $email->AddAttachment( $file_to_attach , 'NameOfFile.pdf' );
    return $email->Send();
    
    }
    Who on earth told you PHP only works on Linux based operating systems...
    • Thread Starter
    Offline

    21
    ReputationRep:
    (Original post by IWMTom)
    Read the documentation; it's self explanatory
    i dont understand the documentation

    is there anything else i can follow

    i have looked online on youtube but they only provide tutorials for sending the form to your own personal email address rather than to the email thats been filled out in the field text
    • Community Assistant
    Online

    18
    ReputationRep:
    (Original post by study beats)
    i dont understand the documentation

    is there anything else i can follow

    i have looked online on youtube but they only provide tutorials for sending the form to your own personal email address rather than to the email thats been filled out in the field text
    You should probably learn the basics first, using a typical educational resource.

    My advice to you is to focus on learning one language before jumping into another.
    Offline

    15
    ReputationRep:
    (Original post by IWMTom)
    Who on earth told you PHP only works on Linux based operating systems...
    I'm perhaps misinformed, and couldn't possibly tell you who had said it, I've always been lead to believe that if you want PHP you go for Linux, you want C+ you go for Windows. But then servers etc are too complex for my understanding, I only code websites as a hobby
    • Community Assistant
    Online

    18
    ReputationRep:
    (Original post by Whispers)
    I'm perhaps misinformed, and couldn't possibly tell you who had said it, I've always been lead to believe that if you want PHP you go for Linux, you want C+ you go for Windows. But then servers etc are too complex for my understanding, I only code websites as a hobby
    C+? You've lost me...
    Offline

    15
    ReputationRep:
    (Original post by IWMTom)
    C+? You've lost me...
    Have I? Oh dear :ciao:
    Perhaps that's a good thing, as we are going a tad off topic :woo:
    • Community Assistant
    Online

    18
    ReputationRep:
    (Original post by Whispers)
    Have I? Oh dear :ciao:
    Perhaps that's a good thing, as we are going a tad off topic :woo:
    Touché
 
 
 
  • See more of what you like on The Student Room

    You can personalise what you see on TSR. Tell us a little about yourself to get started.

  • Poll
    Should Spain allow Catalonia to declare independence?
  • See more of what you like on The Student Room

    You can personalise what you see on TSR. Tell us a little about yourself to get started.

  • The Student Room, Get Revising and Marked by Teachers are trading names of The Student Room Group Ltd.

    Register Number: 04666380 (England and Wales), VAT No. 806 8067 22 Registered Office: International House, Queens Road, Brighton, BN1 3XE

    Quick reply
    Reputation gems: You get these gems as you gain rep from other members for making good contributions and giving helpful advice.