Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: php

  1. #1
    New to the CF scene
    Join Date
    Oct 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    php

    I am new to php, firstly what does php mean, secondly and more seriously I would like to know how to send a attachment as part of a mail using the mail function..

    I copied the following code off the net it works but I dont know how to make it work to send an attachment to.

    <?php
    //define the receiver of the email
    $to ="lawwz@hotmail.com";
    // define the subject
    $subject = "Testing mail function";
    // define the message to be send each line should be separated with a \n
    $message ="Hello there how are you\nfine thanks ";
    //define the headers we want passed. Note they are separated with \r\n
    $headers ="From: lawwz@hotmail.com\n";
    $headers .="Reply-To: lawwz@hotmail.com";
    //send the mail
    $mail_sent = @mail[/B]($to, $subject, $message, $headers);
    echo $mail_sent ? "Mail sent" : "Mail failed";
    ?>


    Also I get a waring with this code but if I change the last line to @mail instead of mail(...) it doesnt give the warning?

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    The acronym PHP is recursive.. it stands for PHP Hypertext Preprocessor. Clever I know.

    Anyways you should take a look at the manual, it has a nice little introduction to PHP and how it works. In the left column the question "What is PHP?" is asked and answered.

    http://www.php.net

    The "@" sign suppresses warnings and errors. It doesn't do anything to fix what's actually wrong, and makes it extremely difficult to troubleshoot and debug problems. It's a horrible way to "fix" crappy code. The _only_ reason to use it is if you are a terrible programmer who doesn't know how to code.

    Sending attachments using the mail() function can be surprisingly challenging. It's definitely not a "beginner" task, but if you Google +php +email +attachment you'll find several tutorials on the subject.

    My personal favorite way of doing it is by using a third-party open source package called PHP Mailer. Makes it pretty simple.

    http://phpmailer.worxware.com/


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •