Results 1 to 10 of 10

Thread: Mail

  1. #1
    Join Date
    Feb 2006
    Posts
    158
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Mail

    I'm trying to figure out how to use the mail command in PHP, but it won't work for some reason. I have a couple general ideas as to why it doesn't work, but I don't know if any of them are the correct reason. Here are my ideas:

    -the mail function doesn't work in PHP 4.1.03 (i think is the version)
    -the mail function doesn't work unless run from a server, as in, when testing it on my home computer for developmental purposes, it won't work
    -smtp.yahoo.com is malfunctioning
    -i'm writing the script wrong

    A couple of those could all be the reason, whereas a couple could be completely dumb ideas as to why it doesnt work. But could somebody please help clear this up for me?

    Thanks in advance.

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    -the mail function doesn't work in PHP 4.1.03 (i think is the version)
    Should do, as far as I remember.
    -the mail function doesn't work unless run from a server, as in, when testing it on my home computer for developmental purposes, it won't work
    You're using a remote server (smtp.yahoo.com).
    -smtp.yahoo.com is malfunctioning
    Can you send email? If so, it's not malfunctioning.

    Which only leaves:
    -i'm writing the script wrong
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Feb 2006
    Posts
    158
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ah, bummer.

    I thought i correctly copied the Mail script right out of the book to see if it'd work.

    Could it be that the sendmail_from part of the [Mail] portion is entered incorrectly?
    the code looks like this i beleive:
    Code:
    ;sendmail_from = myemail@yahoo.com
    That semi-colon before the sendmail thing, could that affect the situation?
    If not, then I'm all out of options other than I'm writing it wrong .

    Thanks.

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Well, I guess it just could, being as it causes PHP to completely ignore anything after the semicolon. I guess that could cause a problem, in a few rare cases...
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Feb 2006
    Posts
    158
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Allright, well i'll remove the semicolon there, and then i'll rewrite my script .

    Thanks, Twey.

  6. #6
    Join Date
    Feb 2006
    Posts
    158
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    One last thing. I'm new to PHP, just started learning it this week. But can you help me find whats wrong with my code?

    Code:
    <html>
    <?php
    $to = "myemail@yahoo.com";
    $subj = "Test";
    $message = "This is a mail service test message.";
    $mailsend = mail($to,$subj,$message);
    if (!$mailsend)
    {
       echo "Mail not sent.";
    }
    else 
    {
      echo "Mail sent.";
    }
    ?>
    </html>
    That is my entire code, and it's supposed to execute the mail function immediately when the page loads, or so I've understood.

    But that's my code, is something wrong with it that would cause me to get this outcome: Mail not sent.
    Every time i try to run the script?

  7. #7
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    it's supposed to execute the mail function immediately when the page loads, or so I've understood.
    Not quite; it should execute the mail() function when the page is requested. PHP, as a server-side language, doesn't know or care what happens after the page has been sent from the server.

    Your firewall could be blocking PHP from connecting to the SMTP server. Try allowing it and seeing what happens. If that fails, write your own simple mail() function using fsockopen() and see where it dies.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  8. #8
    Join Date
    Feb 2006
    Posts
    158
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    So, the mail() function won't execute when my page loads? Do i have to link to the page or something?

  9. #9
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    So, the mail() function won't execute when my page loads?
    No, it executes before your page loads (for the client, that is)
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  10. #10
    Join Date
    Feb 2006
    Posts
    158
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Allright, thanks.
    So now I just have to make sure I'm coding it correctly and I'm all set.

    Thanks, Twey.

Bookmarks

Posting Permissions

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