Results 1 to 15 of 15

Thread: PHP and Sendmail

  1. #1

    Thread Starter
    Member UConnVendetta's Avatar
    Join Date
    Jul 2003
    Location
    Madison, CT, USA
    Posts
    36

    PHP and Sendmail

    I'm looking for an easy way to send mail based on information that is inputted into a form. I tried downloading a mail server, configuring it, and using a cgi script, but its not working, and with a delivery date of 8/17, I have little time to learn anything new. I've heard of qmail, but it only works on UNIX and the site I'm hosting it from uses Apache on a Windows machine. Any ideas or quick solutions would be greatly appreciated.
    Jazzman Will Rosenberg
    Chief Admin of [Vendetta]
    http://vendetta.n3.com
    AIM: UConnVendetta, CollegeGuy184

  2. #2
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    php has it's own mail function.

    mail($to,$subject,$message,$extra_headers);

    http://www.php.net/manual/en/ref.mail.php

  3. #3

    Thread Starter
    Member UConnVendetta's Avatar
    Join Date
    Jul 2003
    Location
    Madison, CT, USA
    Posts
    36

    Wait one second, let me get this straight.

    So in order to use PHP's mail() function, I don't need a seperate mail app, nor do I need to learn sendmail? It sounds too good to be true!

    Dont I still have to give PHP some SMTP address or is that taken care of as well? Cuz if so, then I'm back to where I started, unless you could tell me about a simple SMTP program so something like that.
    Jazzman Will Rosenberg
    Chief Admin of [Vendetta]
    http://vendetta.n3.com
    AIM: UConnVendetta, CollegeGuy184

  4. #4
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    if php is setup correctly and apache is setup correct you don't need anything.

    is it your machine or a HOST?

    if yours and you have an email addy then you can do it no problem.

  5. #5

    Thread Starter
    Member UConnVendetta's Avatar
    Join Date
    Jul 2003
    Location
    Madison, CT, USA
    Posts
    36

    Server Info

    I run the site off of a seperate computer that uses Apache. I also have an AOL and Hotmail email accounts. Do I enter into the php config file the address of one of my email smtp's or will it work by itself?
    Jazzman Will Rosenberg
    Chief Admin of [Vendetta]
    http://vendetta.n3.com
    AIM: UConnVendetta, CollegeGuy184

  6. #6
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    you don't have email on the server that has php on it? is it your server? or a HOST?

  7. #7

    Thread Starter
    Member UConnVendetta's Avatar
    Join Date
    Jul 2003
    Location
    Madison, CT, USA
    Posts
    36

    Um...

    It's my server, I host it from my dorm room via the UConn campus LAN, using Apache, with PHP installed. I am not hosting it using a third party domain or anything like that. All I have is a redirection link that brings people to my IP address, and my server has no mail server installed or like mail program. For email, I usually use Hotmail.

    I am familiar now, after reading a few articles, how to set up the PHP code:

    PHP Code:
    <!-- The following code is on my submission page -->
    <
    form method=post action="thanks.php">
        <
    table border="0" cellspacing="0" cellpadding="0">
            <
    tr
                <
    td>Your Name:</td>
                <
    td>
                    <
    input type="text" name="name">
                </
    td>
            </
    tr>
            <
    tr
                <
    td>Your E-mail:</td>
                <
    td>
                    <
    input type="text" name="theiremail">
                </
    td>
            </
    tr>
            <
    tr>
                <
    td valign="top">Your Message:</td>
                <
    td>
                    <
    textarea name="message"></textarea>
                </
    td>
            </
    tr>
            <
    tr
                <
    td colspan="2">
                    <
    input type="submit" name="Submit" value="Send_Form">
                </
    td>
            </
    tr>
        </
    table>
    </
    form
    PHP Code:
    <!-- then this code is at the top of my thanks.php page -->
    <?php  
    if($sentemail == "2"){  //check to make sure ppl can't spam me
    include("sorry.php");  //displays page if spamming

    }else{  

    $num $sentmessage 1;  
    setcookie("sentemail","$num",time()+600); //set the cookie 

    $email "Sender Name:\t$name\nSender E- Mail:\t$theiremail\nMessage:\t$message\nIP:\t$RE
    MOTE_ADDR\n\n"
    //sets email message
    $to "[email protected]"
    $subject "Site Message"
    $mailheaders "From: $theiremail <> \n"
    $mailheaders .= "Reply-To: $theiremail\n\n"
    mail($to$subject$email$mailheaders); //sends mail
    include("thanksecho.php"); //sends user to customized thank you page

    ?>
    The mail section of my PHP.ini file is currently setup like this:

    [mail function]
    ; For Win32 only.
    SMTP = localhost

    ; For Win32 only.
    sendmail_from = [email protected]

    ; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
    ;sendmail_path =


    Once again, I am running windows on my server and must use another site's SMTP since there is no mail on my server. 1). How must I configure the [mail function] section of my php.ini file to reflect my situation. 2). Does my sendmail_from variable have to be from the same domain as the SMTP variable (i.e. if i use hotmail's SMTP address, should i use my hotmail email address as the sendmail_from variable/does it matter?)?

    Hopefully this message is easier to understand. Thank you very much for your reply.
    Jazzman Will Rosenberg
    Chief Admin of [Vendetta]
    http://vendetta.n3.com
    AIM: UConnVendetta, CollegeGuy184

  8. #8

    Thread Starter
    Member UConnVendetta's Avatar
    Join Date
    Jul 2003
    Location
    Madison, CT, USA
    Posts
    36

    Appendages from everywhere!!!! Argh!

    One more quick question: how long can a line of php code be? The $email string is going to be much longer than the one in the example. I know in JavaScript you can write:

    my_variable = 'blah blah blah blah'
    + 'blah blah blah blah blah blah'
    + 'more blah blah blahs';

    Can you do this in PHP if there is a problem with the length of a line of code?

    Thanks
    Last edited by UConnVendetta; Aug 16th, 2003 at 12:43 AM.
    Jazzman Will Rosenberg
    Chief Admin of [Vendetta]
    http://vendetta.n3.com
    AIM: UConnVendetta, CollegeGuy184

  9. #9
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    I understand what you need. I am just trying to understand how you have internet without email.

    you could try to use your hotmail but I don't belive it will work. what you really want is somethign to the effect "mail.host.com"

    but since you don't have one then you are out of luck. you will need to add a mail server to get it and then you are look at big bucks. what form of dialup do you have?

  10. #10
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    Re: Appendages from everywhere!!!! Argh!

    Originally posted by UConnVendetta
    One more quick question: how long can a line of php code be? The $email string is going to be much longer than the one in the example. I know in JavaScript you can write:

    my_variable = 'blah blah blah blah'
    + 'blah blah blah blah blah blah'
    + 'more blah blah blahs';

    Can you do this in PHP if there is a problem with the length of a line of code?

    Thanks
    In PHP:

    Code:
    $my_variable = 'blah blah blah blah'
        . 'blah blah blah blah blah blah'
        . 'more blah blah blahs';
    or

    Code:
    $my_variable = 'blah blah blah blah';
    $my_variable .= 'blah blah blah blah blah blah';
    $my_variable .= 'more blah blah blahs';
    My evil laugh has a squeak in it.

    kristopherwilson.com

  11. #11
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    or

    PHP Code:
    $my_variable 'blah blah blah blah'
         'blah blah blah blah blah blah'
         'more blah blah blahs'


  12. #12
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by phpman
    or

    PHP Code:
    $my_variable 'blah blah blah blah'
         'blah blah blah blah blah blah'
         'more blah blah blahs'

    He didn't ask for a parse error?

    Edit: I even ran it to double check and that gave me a:

    Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in d:\user files\kristopher\site\test.php on line 3
    My evil laugh has a squeak in it.

    kristopherwilson.com

  13. #13
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    you are right, I left the single quotes in

    PHP Code:
    $my_variable 'blah blah blah blah
         blah blah blah blah blah blah 
         more blah blah blahs'


  14. #14
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by phpman
    you are right, I left the single quotes in

    PHP Code:
    $my_variable 'blah blah blah blah
         blah blah blah blah blah blah 
         more blah blah blahs'

    That's better.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  15. #15

    Thread Starter
    Member UConnVendetta's Avatar
    Join Date
    Jul 2003
    Location
    Madison, CT, USA
    Posts
    36
    BTW, before i start, thanks for help with my length of a variable question

    Originally posted by phpman
    I understand what you need. I am just trying to understand how you have internet without email.

    you could try to use your hotmail but I don't belive it will work. what you really want is somethign to the effect "mail.host.com"

    but since you don't have one then you are out of luck. you will need to add a mail server to get it and then you are look at big bucks. what form of dialup do you have?
    I currently am running my server on my university's LAN. I have a problem with windows right now though, probably some virus or hacker got through before i updated my security so I'm re-installing windows.

    I'm running Apache's HTTP Server. with no additional mail server. Before my comp crahsed, I was getting an error telling me that I was missing a from header or the sendmail_from variable in my php.ini file was missing. I included both, so maybe the problem is because I tried using a 3rd party's SMTP for mailing, but not using my email address for that site. I'm not sure what is wrong.
    Jazzman Will Rosenberg
    Chief Admin of [Vendetta]
    http://vendetta.n3.com
    AIM: UConnVendetta, CollegeGuy184

Posting Permissions

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



Click Here to Expand Forum to Full Width