mail() problems, how do I print out what the error is?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • James M. Luongo

    mail() problems, how do I print out what the error is?

    Hello,

    I am having problems with the mail() function, but I don't know what the
    problems are.

    Here is a snippet of code:

    $to = "jmluongo@comca st.net";
    $from = "Gallery@gafok. com";
    $subject = "Gallery Comment";
    $msg = "You have received a comment from " . $commenter_name ;
    $msg .= "\n\nAt index: " . $index;
    $msg .= "\n\nIP address: " . $IPNumber;
    $msg .= "\n\nCommen t: " . stripslashes($c omment_text);
    mail($to, $subject, $msg, "$from") or print "Cannot send mail \n";

    I keep getting the "Cannot send mail" message and I want to see why. Is
    there any way to see what the error really is?

    thanks,

    _James Luongo

  • Spidah

    #2
    Re: mail() problems, how do I print out what the error is?

    Check the [Mail Function] section of your php.ini file and make sure the
    path to your mail server is correct.

    Hamilton


    "the web site for web sites"

    "James M. Luongo" <jmluongo@nospa m.comcast.net> wrote in message
    news:3F0CAF93.4 080506@nospam.c omcast.net...[color=blue]
    > You are correct about the From: field, but that didn't solve the
    > problem. It's still not sending the mail and I wish to find out what
    > the error code or message is.
    >
    > -James
    >
    > Joshua Ghiloni wrote:
    >[color=green]
    > > James M. Luongo wrote:
    > >[color=darkred]
    > >> Hello,
    > >>
    > >> I am having problems with the mail() function, but I don't know what
    > >> the problems are.
    > >>
    > >> Here is a snippet of code:
    > >>
    > >> $to = "jmluongo@comca st.net";
    > >> $from = "Gallery@gafok. com";
    > >> $subject = "Gallery Comment";
    > >> $msg = "You have received a comment from " . $commenter_name ;
    > >> $msg .= "\n\nAt index: " . $index;
    > >> $msg .= "\n\nIP address: " . $IPNumber;
    > >> $msg .= "\n\nCommen t: " . stripslashes($c omment_text);
    > >> mail($to, $subject, $msg, "$from") or print "Cannot send mail \n";
    > >>
    > >> I keep getting the "Cannot send mail" message and I want to see why.
    > >> Is there any way to see what the error really is?
    > >>
    > >> thanks,
    > >>
    > >> _James Luongo
    > >>[/color]
    > > Your From: header is wrong. Read up on the RFC or omit it. I do believe
    > > that your From header should look like (untested)
    > >
    > > $from = "From: Gallery@gafok.c om\r\n";
    > >[/color]
    >[/color]


    Comment

    • Jon Kraft

      #3
      Re: mail() problems, how do I print out what the error is?

      "James M. Luongo" <jmluongo@nospa m.comcast.net> wrote:
      [color=blue]
      > I am having problems with the mail() function, but I don't know what the
      > problems are.
      >
      > Here is a snippet of code:
      >
      > $to = "jmluongo@comca st.net";
      > $from = "Gallery@gafok. com";
      > $subject = "Gallery Comment";
      > $msg = "You have received a comment from " . $commenter_name ;
      > $msg .= "\n\nAt index: " . $index;
      > $msg .= "\n\nIP address: " . $IPNumber;
      > $msg .= "\n\nCommen t: " . stripslashes($c omment_text);
      > mail($to, $subject, $msg, "$from") or print "Cannot send mail \n";[/color]

      Hi James,

      The correct From header would be (and don't forget \r\n):

      $from = "From: Gallery@gafok.c om\r\n";
      // ..
      mail($to, $subject, $msg, $from) or print "Cannot send mail \n";

      If you are on Linux/Unix, check the path to sendmail in php.ini - on
      Windows make sure you've set the SMTP server entry in php.ini to a valid
      SMTP server.

      HTH;
      JOn

      Comment

      • Richard Hockey

        #4
        Re: mail() problems, how do I print out what the error is?

        I'd recommend checking php.ini to see if php is writing an error log file.
        If it is, check in the error log, there may be more information on the
        problem in there.

        "James M. Luongo" <jmluongo@nospa m.comcast.net> wrote in message
        news:3F0C9C3B.6 0404@nospam.com cast.net...[color=blue]
        > Hello,
        >
        > I am having problems with the mail() function, but I don't know what the
        > problems are.
        >
        > Here is a snippet of code:
        >
        > $to = "jmluongo@comca st.net";
        > $from = "Gallery@gafok. com";
        > $subject = "Gallery Comment";
        > $msg = "You have received a comment from " . $commenter_name ;
        > $msg .= "\n\nAt index: " . $index;
        > $msg .= "\n\nIP address: " . $IPNumber;
        > $msg .= "\n\nCommen t: " . stripslashes($c omment_text);
        > mail($to, $subject, $msg, "$from") or print "Cannot send mail \n";
        >
        > I keep getting the "Cannot send mail" message and I want to see why. Is
        > there any way to see what the error really is?
        >
        > thanks,
        >
        > _James Luongo
        >[/color]


        Comment

        Working...