[RESOLVED] Help with PHP "retval():
Page 1 of 2 12 LastLast
Results 1 to 15 of 21

Thread: [RESOLVED] Help with PHP "retval():

  1. #1
    Senior Member
    Join Date
    May 2013
    Location
    NYS
    Posts
    128

    resolved [RESOLVED] Help with PHP "retval():

    I have recently come across the retval function. It looks like a valuable tool for my forms, but I can't get it to work for me. Yes, I'm a rough newbie.

    My code is simply:
    PHP Code:
    if( $retval == true)
       {
          echo 
    "Message sent successfully...";
       }
       else
       {
          echo 
    "Message could not be sent...";
       } 
    Unfortunately it responds with:
    "Notice: Undefined variable: retval in C:\xampp\htdocs\formcheck2.php on line 55
    Message could not be sent... "
    when the code is run and of course it doesn't work.

    After a little research, It appears that it needs to be defined somehow. I've looked at a LOT of places researching it, but I cannot figure out how it needs to be defined to work with the mail function mail(). There are all kinds of examples around but nothing I can seem to translate to work with the mail function.

    Can anyone assist me in getting it to work to verify that the mail was sent from my form? I feel sure the a answere is going to be obvious, but ... it sure isn't right now.



    Thanks in Advance,

    Rivet`
    Last edited by Rivet; 06-19-2013 at 08:33 PM. Reason: Add
    Share on Google+

  2. #2
    Senior Member traq's Avatar
    Join Date
    Jun 2011
    Location
    so.Cal
    Posts
    949
    $retval in your code snippet is not a function. It is a variable (hence, "undefined variable").

    ----------------------edit

    I would suspect the other part of this code you "came across" was something like this
    PHP Code:
    <?php

    // mail() returns TRUE on success
    $retval mail$to,$subject,$body,$headers );

    // therefore, $retval will be TRUE *if* the mail() function was successful
    if( $retval === true ){ 
        echo 
    "Message sent successfully..."

    else{ 
        echo 
    "Message could not be sent..."
    }
    ...?
    Last edited by traq; 06-19-2013 at 09:23 PM.
    Share on Google+

  3. #3
    Pna lbh ernq guvf¿
    Join Date
    Jul 2004
    Location
    Kansas City area
    Posts
    19,393
    Quote Originally Posted by traq View Post
    $retval in your code snippet is not a function.
    Nor does retval() exist as a core PHP function.
    Share on Google+

  4. #4
    Senior Member
    Join Date
    May 2013
    Location
    NYS
    Posts
    128
    Good show; NOW it makes sense! And yes, your code-estimate is exactly what I came across but there wasn't any hint of retval ever having been defined. Then when I searched for "PHP retval()" I found it appeared to be a PHP function, leading me to believe that's what I was working with.
    I'm not arguing your point that it is not a core PHP function; I'm sure it's a misunderstanding on my part.

    Any suggestions on how to query the server to see if a mail was actually sent out?

    That code indicated it verified the sending of an e-mail, but ... well, you see how I jumped to the wrong conclusion, I think. I have it bookmarked so I'll go look some more at the site where I found it.

    Thanks & Regards,

    Rivet`

    PS - The PHP page I should have read a lot closer: http://php.net/manual/en/function.system.php ! NOW I know!
    Share on Google+

  5. #5
    Senior Member traq's Avatar
    Join Date
    Jun 2011
    Location
    so.Cal
    Posts
    949
    Quote Originally Posted by Rivet View Post
    Any suggestions on how to query the server to see if a mail was actually sent out?
    send it to your own email address; check your mail.
    Share on Google+

  6. #6
    Senior Member
    Join Date
    May 2013
    Location
    NYS
    Posts
    128
    Quote Originally Posted by traq View Post
    send it to your own email address; check your mail.
    Yes, I'm well aware of that and I am receiving the e-mails. But it's not what I asked about: I want to know how to tell with some sort of server response that the e-mail was sent out or it was not sent, right then & there. My telling a visitor their e-mail was sent and having actual verification of it being sent is what I'm after. I'm looking to detect and use the ACK that the server sends back upon having sent an e-mail; It's a piece of information that does exist; the server responds with an ack when an e-mail has successfully been sent FROM the server. I'm trying to figure out what that ACK is and how to detect it.

    Thanks for your response,

    Rivet`
    Share on Google+

  7. #7
    Senior Member
    Join Date
    May 2013
    Location
    NYS
    Posts
    128

    Lightbulb

    I've resolved the situation but not the way I wanted to. Since the e-mail address involved is used only for that one purpose, I set up an auto-responder to send an acknowledgement that the mail has arrived. It's not exactly what I wanted, but it's close enough to be usable.

    My thanks to all respondents; as usual, I learned a lot from them in the process.

    Best Regards,

    Rivet`
    Share on Google+

  8. #8
    Senior Member traq's Avatar
    Join Date
    Jun 2011
    Location
    so.Cal
    Posts
    949
    Quote Originally Posted by Rivet View Post
    Yes, I'm well aware of that and I am receiving the e-mails. But it's not what I asked about: I want to know how to tell with some sort of server response that the e-mail was sent out or it was not sent, right then & there. My telling a visitor their e-mail was sent and having actual verification of it being sent is what I'm after. I'm looking to detect and use the ACK that the server sends back upon having sent an e-mail; It's a piece of information that does exist; the server responds with an ack when an e-mail has successfully been sent FROM the server. I'm trying to figure out what that ACK is and how to detect it.
    mail() doesn't (can't) know if the email was actually sent or not; much less if it will actually arrive at its destination. It returns true if the email server accepts the message for delivery; false if not.
    Share on Google+

  9. #9
    Senior Member
    Join Date
    May 2013
    Location
    NYS
    Posts
    128
    Quote Originally Posted by traq View Post
    mail() doesn't (can't) know if the email was actually sent or not; much less if it will actually arrive at its destination. It returns true if the email server accepts the message for delivery; false if not.
    I never said ANYTHING about wanting to know if the mail was DELIVERED. I only asked for a way to get the ACK from the serve r that IT received the e-mail! At the end of the sending, there IS a response to the transaction indicating that the mail was accepted (or not). I fail to see what's so hard to understand about that, I'm afraid.

    In your own language, " It returns true if the email server accepts the message for delivery; false if not. " I think it was pretty clearly stated in your quote above only I didn't use the "correct words" you wanted to see. This is the ONLY place I've posted this question that has had trouble understanding what it was about and unfortunately , it's not an isolated incident here. I received a workable solution, by the way, from a newsgroup. He explained what was wrong with my code and suggested precisely what I needed to do to get the ACK I wanted.
    Don't take this personally because it seems to be "the culture" here to answer queries that don't contain any attempt at an answer to the query.

    Regards,

    Rivet`
    Share on Google+

  10. #10
    Senior Member traq's Avatar
    Join Date
    Jun 2011
    Location
    so.Cal
    Posts
    949
    Quote Originally Posted by Rivet View Post
    I never said ANYTHING about wanting to know if the mail was DELIVERED. I only asked for a way to get the ACK from the serve r that IT received the e-mail! At the end of the sending, there IS a response to the transaction indicating that the mail was accepted (or not). I fail to see what's so hard to understand about that, I'm afraid.

    In your own language, " It returns true if the email server accepts the message for delivery; false if not. " I think it was pretty clearly stated in your quote above only I didn't use the "correct words" you wanted to see. This is the ONLY place I've posted this question that has had trouble understanding what it was about and unfortunately , it's not an isolated incident here. I received a workable solution, by the way, from a newsgroup. He explained what was wrong with my code and suggested precisely what I needed to do to get the ACK I wanted.
    Don't take this personally because it seems to be "the culture" here to answer queries that don't contain any attempt at an answer to the query.

    Regards,

    Rivet`
    [emphasis added]
    ...in contrast to your prior posts:
    Quote Originally Posted by Rivet View Post
    Any suggestions on how to query the server to see if a mail was actually sent out?
    [emphasis added]
    Quote Originally Posted by Rivet View Post
    I want to know how to tell with some sort of server response that the e-mail was sent out or it was not sent ...
    [emphasis added]
    I am not trying to be difficult. I answered the question you asked, in as clear and concise terms as I could manage. Yes, I agree with you; I do think that it was "pretty clearly stated."

    to reiterate, mail's return value (true or false) indicates whether PHP received that acknowledgement from the mail queue (not if it was "actually sent").

    This answer might be more specific than you expected because there is room for confusion - "accepted" vs. "sent" vs. "delivered" - until now, there was no clear indication as to whether or not you were even aware of the differences. I am not holding this "against you"; I simply want to give you a helpful answer that will not lead to further problems or misunderstandings later. I felt I had a clear understanding of your question (I still feel that way, in fact), and I was not waiting for you to "say the magic words" or make any other sort of supplication.

    If you do not want to accept such clarifications or details in your answers, you are of course free to ignore them.

    However, I do not believe it is inappropriate to offer them, and I will continue to do so. I hope you do not take offense at this, as none is intended.
    Last edited by traq; 06-20-2013 at 10:35 PM.
    Share on Google+

  11. #11
    Pna lbh ernq guvf¿
    Join Date
    Jul 2004
    Location
    Kansas City area
    Posts
    19,393
    Quote Originally Posted by Rivet View Post
    I never said ANYTHING about wanting to know if the mail was DELIVERED. I only asked for a way to get the ACK from the serve r that IT received the e-mail! At the end of the sending, there IS a response to the transaction indicating that the mail was accepted (or not). I fail to see what's so hard to understand about that, I'm afraid.
    What's so hard to understand is that you either don't fully understand how the mailing process works, or else you aren't able to formulate the proper question.

    Quote Originally Posted by Rivet View Post
    In your own language, " It returns true if the email server accepts the message for delivery; false if not. " I think it was pretty clearly stated in your quote above only I didn't use the "correct words" you wanted to see. This is the ONLY place I've posted this question that has had trouble understanding what it was about and unfortunately , it's not an isolated incident here.
    Yes, we have no resident psychics here, so if you ask the wrong question, you'll get the wrong answer. Every time. I promise.

    For example, if you ask these questions:
    Quote Originally Posted by Rivet View Post
    Any suggestions on how to query the server to see if a mail was actually sent out?
    Quote Originally Posted by Rivet View Post
    I want to know how to tell with some sort of server response that the e-mail was sent out or it was not sent, right then & there.
    you'll get an entirely different response than if you ask how to determine if the message was "accepted for delivery." It's not just "correct words" - the two are completely separate parts of the transaction.

    Quote Originally Posted by Rivet View Post
    I received a workable solution, by the way, from a newsgroup. He explained what was wrong with my code and suggested precisely what I needed to do to get the ACK I wanted.
    Don't take this personally because it seems to be "the culture" here to answer queries that don't contain any attempt at an answer to the query.
    Don't take this personally, but if you've found a newsgroup where the people ignore the actual questions you ask and instead answer the questions you should have asked, I would recommend you stick with using that newsgroup and only that newsgroup.

    EDIT: One of these days I swear I'll remember to refresh old tabs before replying. One of these days...
    Share on Google+

  12. #12
    Senior Member
    Join Date
    May 2013
    Location
    NYS
    Posts
    128
    For whatever reason multi-quote doesn't seem to be working so if I the quoting gets screwed up, that's my fault. I thought you deserved a response to this, so I'm responding to you; I'm the kind of person who is sometimes unnecessarily truthful and believe in saying what I think and appreciate others who do the same.

    =bradgrafelman;11030181]What's so hard to understand is that you either don't fully understand how the mailing process works, or else you aren't able to formulate the proper question.
    I have a reasonable knowledge of servers and how they function, and web sites too but you're likely right that I'm unable to formulate the questions to what you call "proper", and I'm aware of it; that's precisely why I chose a forum for Newbies; I expected that if I wasn't clear on something I'd be queried to get clarification. Which I've tried to provide.
    And the reason I'm aware of my problem is because I am the victim of a serious brain concussion that took away a lot of what I knew and nearly destroyed my short-term memory. I managed to get past the "learning disabled' label a couple of years ago and am using PHP as one of my exercises to continue improving my memory. So I do have difficulty expressing myself and hard as I try I often look into the wrong end of the tunnel although in the aggregate I am usually able to describe things as long as I take my time.

    Yes, we have no resident psychics here, so if you ask the wrong question, you'll get the wrong answer. Every time. I promise.
    LOL! Quite true, I'm sure! [/QUOTE]


    ...
    Don't take this personally, but if you've found a newsgroup where the people ignore the actual questions you ask and instead answer the questions you should have asked, I would recommend you stick with using that newsgroup and only that newsgroup.
    Perish the thought; There's nothing to be taken personally there, and I do again notice you again mentioned as the question properly, once more supporting my past comments.
    Also it's pretty lame IMO to recommend limiting one's self to any single source for anything, reference or otherwise. I really feel you need to rethink that particular attitude; few people are likely to take it seriously. Two of the newsgroups I referred to did as one would expect with a newbie: asked for further clarification. I may have problems as I admitted earlier, but I can think for myself and am not affected by silly comments like that.

    EDIT: One of these days I swear I'll remember to refresh old tabs before replying. One of these days...[/QUOTE]

    I am sorry but I have no idea what you mean by that. I'm tempted to ask for clarification but that's apparently not how this newsgroup works.

    Regards,

    Rivet`
    Share on Google+

  13. #13
    Settled 4 red convertible dalecosp's Avatar
    Join Date
    Jul 2002
    Location
    Accelerating Windows at 9.81 m/s....
    Posts
    7,674
    Quote Originally Posted by Rivet
    Quote Originally Posted by bradgrafelman
    EDIT: One of these days I swear I'll remember to refresh old tabs before replying. One of these days...
    I am sorry but I have no idea what you mean by that. I'm tempted to ask for clarification but that's apparently not how this newsgroup works.
    I'm fairly certain that what he meant was that while he was crafting a reply to some post or another, someone else added information to the thread that he would've like to have known about before he pushed "submit" on his own reply.

    And, to keep with our somewhat pedantic "culture", a newsgroup is something you use with a newsreading program (much like, or even integrated into, an MUA (Mail User Agent)) and operating over NNTP. This is a forum on the WWW.

    Quote Originally Posted by Rivet
    My thanks to all respondents; as usual, I learned a lot from them in the process.

    Best Regards,
    There are some very sharp tacks in this drawer. I'm not one of them yet, but I do aspire to learn as well.

    Best Regards to you, too.
    /!!\ mysql_ is deprecated --- don't use it! Tell your hosting company you will switch if they don't upgrade! /!!!\ ereg() is deprecated --- don't use it!

    dalecosp "God doesn't play dice." --- Einstein "Perl is hardly a paragon of beautiful syntax." --- Weedpacket

    Getting Help at All --- Collected Solutions to Common Problems --- Debugging 101 --- Unanswered Posts --- OMBE: Office Machines, Business Equipment
    Share on Google+

  14. #14
    Senior Member
    Join Date
    May 2013
    Location
    NYS
    Posts
    128
    Quote Originally Posted by dalecosp View Post
    I'm fairly certain that what he meant was that while he was crafting a reply to some post or another, someone else added information to the thread that he would've like to have known about before he pushed "submit" on his own reply.
    Perhaps; not for me to judge, really. If he wanted to be understood, I'm sure he could have made it clearer. If I was supposed to understand by implication, I did not. Each to their own thoughts, I figure.


    And, to keep with our somewhat pedantic "culture", a newsgroup is something you use with a newsreading program (much like, or even integrated into, an MUA (Mail User Agent)) and operating over NNTP. This is a forum on the WWW.
    LOL! Thanks, but I'm a newbie when it comes to PHP, but not for other things. I use Mozilla Thunderbird to read newsgroups and IE or Firefox to go on forums et al. Believe me, it's not necessary to define those for me.
    Even though they're becoming dinosaurs I still prefer the text-based non-GUI and straight forward values of the newsgroups. There are still some excellent professional newsgroups around which I participate on often. I enjoy helping people and hope I can get to that point with PHP eventually.
    Forums are OK, but the GUI is a terrible waste of bandwidth and unnecessary colors and features, although I will admit some of them are pretty handy. I've always thought they needed a "Plain Text" setting for times when all the hoopla isn't any real benefit.
    This is one of two forums I like for the learning opportunities.

    There are some very sharp tacks in this drawer. I'm not one of them yet, but I do aspire to learn as well.
    I can tell there are, no argument there. It's great IME as long as you phrase things like a professional, all proper and completely concise, which is not something one should expect from admitted newbies. I'm not saying that about you; it's more a general observation of a very few people who might be reaching burn-out stages, or Peter Principled themselves, whatever. I have this unfortunate habit of being honest about things.

    Best Regards to you, too.
    Cheers dalecosp,

    Have a good weekend,

    Rivet`
    Last edited by Rivet; 06-21-2013 at 08:49 PM. Reason: spelling
    Share on Google+

  15. #15
    Senior Member traq's Avatar
    Join Date
    Jun 2011
    Location
    so.Cal
    Posts
    949
    Quote Originally Posted by bradgrafelman View Post
    EDIT: One of these days I swear I'll remember to refresh old tabs before replying. One of these days...
    Quote Originally Posted by dalecosp View Post
    I'm fairly certain that what he meant was that while he was crafting a reply to some post or another, someone else added information to the thread that he would've like to have known about before he pushed "submit" on his own reply.
    Quote Originally Posted by Rivet View Post
    Perhaps; not for me to judge, really. If he wanted to be understood, I'm sure he could have made it clearer. If I was supposed to understand by implication, I did not.
    I can't speak for him, of course, but I'm fairly certain bradgrafelman meant that he did not see my reply before he made his own (in which he cited several of your comments which I had already addressed).


    Quote Originally Posted by Rivet View Post
    ... It's great IME as long as you phrase things like a professional, all proper and completely concise, which is not something one should expect from admitted newbies.
    I understand what you're saying. There's another aspect to the present situation, however: it's not that you didn't phrase your question clearly or professionally, it's that - whether you meant to or not - you were actually asking a different question than you intended (and/or your question -as often happens- evolved and changed along with your understanding of the problem).


    Quote Originally Posted by Rivet View Post
    I have this unfortunate habit of being honest about things.
    Honesty is not bad. I find that, especially on the internet, it is always complimented by patience. Text is a very ambiguous medium and it is extremely easy to jump to conclusions about the attitude with which it was written. I try to find the best possible way some comment could have been meant (even if I'm all but certain that it wasn't meant that way) and respond with that in mind. To repay your honesty, when I read your earlier post, my first impression was that you were being grumpy, defensive, and maybe you wanted to distract attention from the situation by trying to start a flame war. (Again, honesty, not an attack.) But I re-read it before I replied.

    I'm not burnt-out, nor am I here to sit on a pedestal or lecture anyone. I'm here because I think it's a great place to learn and to help others learn. That's it.

    I hope you can continue to enjoy the forums,
    Share on Google+

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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