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 9 of 9
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    Montreal, Canada
    Posts
    644
    Thanks
    0
    Thanked 0 Times in 0 Posts

    mail func doesn't work, but fsockopen to smtp server does?!?

    Why is it that when I connect to my smtp server using fsockopen I can send mail, but when I try to use the function "mail()" it give me an error? I have the same server/port/config in my php.ini as I do in my fsockopen script.

    Err:
    Warning: Unknown error in c:\apache\www\email.php on line **

    My fsock code:
    PHP Code:
    <?php

    $sender 
    "some-honkey@yahoo.com";
    $recv "that-guy-there@hotmail.com";
    $host "mail.server.ca";
    $port 25;
    $subj "My email sunject";
    $body "send body...";
    $connect fsockopen ($host$port$error_num$error_str30)
      or die (
    "error 1");
    if ( 
    $connect ) {
      print 
    fgets ($connect1024);
      
    fputs ($connect"mail from: $sender\r\n");
      
    fputs ($connect"rcpt to: $recv\r\n");
      
    fputs ($connect"data\r\n");
      
    fputs ($connect"Subject: $subj\r\n");
      
    fputs ($connect"$body\r\n");
      
    fputs ($connect".\r\n\r\n");
      
    fclose ($connect);
    } else {
      print 
    "$error_num - $error_str<br>\n";
    }

    ?>
    The mail functions I've tried using were cut and pasted from different tutorials and from people who got the exact same script to work for them, so I know it's not my syntax. My guess is that it because of the usual problem, I'm running apache on windows 2k. Could that be the source of my problem? Are there any other possible sources for errors?

    Thanx.

  • #2
    Regular Coder
    Join Date
    Nov 2002
    Location
    Bristol, UK
    Posts
    932
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, I hate mail(). It is because you have to set it up and then it still is finnicky that I wrote my own mail() replacements ages ago

    goose, stick to doing it yourself - forget about mail()

    ::] krycek [::
    ithium | SOAPI | SDP | PTPScript manual
    "ithium is a non-profit webhost, which is pretty much unique. The mission of ithium is to provide free hosting resources for worthwhile and needy non-profit projects, which otherwise may not be able to obtain such facilities. The money from commercial customers goes to maintain ithium's servers and further development."

  • #3
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,040
    Thanks
    10
    Thanked 92 Times in 90 Posts
    if your php.ini entries are correct then there is no reason that mail() should not work unless your server requires authentication (which it really ought to) , that said your script does not appear to authenticate either (unless you have just removed the user and pass for understandable reasons) , if so check your php.ini again ?

    to be honest I am more surprised that your script below works without a EHLO/HELO in sight!
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #4
    New Coder
    Join Date
    Jan 2003
    Location
    Tulsa, OK
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I agree with firepages, the mail() function should work perfectly given the .ini settings are correct. As far as the authentication part, I just use referral entries to allow sending permissions. Makes life easier.

  • #5
    Regular Coder
    Join Date
    Nov 2002
    Location
    Bristol, UK
    Posts
    932
    Thanks
    0
    Thanked 0 Times in 0 Posts
    yup, he should have some extra stuff in there but oh well

    I personally hate mail(). It's slow, and not very customisable.

    My own mail scripts are a lot faster, and can do a lot more, so I tend to stick to them

    ::] krycek [::
    ithium | SOAPI | SDP | PTPScript manual
    "ithium is a non-profit webhost, which is pretty much unique. The mission of ithium is to provide free hosting resources for worthwhile and needy non-profit projects, which otherwise may not be able to obtain such facilities. The money from commercial customers goes to maintain ithium's servers and further development."

  • #6
    Regular Coder
    Join Date
    Jun 2002
    Location
    Montreal, Canada
    Posts
    644
    Thanks
    0
    Thanked 0 Times in 0 Posts
    my mail server doesn't require authentication or the EHLO command.

  • #7
    Regular Coder
    Join Date
    Nov 2002
    Location
    Bristol, UK
    Posts
    932
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It should still have HELO

    ::] krycek [::
    ithium | SOAPI | SDP | PTPScript manual
    "ithium is a non-profit webhost, which is pretty much unique. The mission of ithium is to provide free hosting resources for worthwhile and needy non-profit projects, which otherwise may not be able to obtain such facilities. The money from commercial customers goes to maintain ithium's servers and further development."

  • #8
    Regular Coder
    Join Date
    Jul 2002
    Location
    Iran
    Posts
    695
    Thanks
    0
    Thanked 0 Times in 0 Posts
    x_goose_x: May I have the address of those tutorials?! I don't know how to send an email via smtp.

    krycek: Are your functions open source?! May I take a look at them?!

  • #9
    Regular Coder
    Join Date
    Nov 2002
    Location
    Bristol, UK
    Posts
    932
    Thanks
    0
    Thanked 0 Times in 0 Posts
    confused_of_life: yup, they are OpenSource you are welcome to take a look.

    Email me at krycek @ soapi . com and we can take it from there

    ::] krycek [::
    ithium | SOAPI | SDP | PTPScript manual
    "ithium is a non-profit webhost, which is pretty much unique. The mission of ithium is to provide free hosting resources for worthwhile and needy non-profit projects, which otherwise may not be able to obtain such facilities. The money from commercial customers goes to maintain ithium's servers and further development."


  •  

    Posting Permissions

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