1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: php: sending an e-mail from a web browser application

Discussion in 'Web Design & Development' started by andynic, Jul 16, 2012.

Thread Status:
Not open for further replies.
  1. andynic

    andynic Thread Starter

    May 25, 2007

    I'm trying to get this test script working:
    $to = "a valid email address";
    $subj = "Test mail";
    $msg = "Hello! This is a simple email message.";
    $hdr = "From: test script";
    $rslt = mail($to, $subj, $msg, $hdr);
    echo "rslt = $rslt<br />";

    If, for "a valid email address", I use my yahoo.com address, I receive the email.
    If, on the other hand, I use my xs4all.nl address (my regular email), no mail arrives, neither in my inbox nor in the spambox.

    The settings in the server's php.ini file are:
    [mail function]
    ; For Win32 only.
    ; http://php.net/smtp
    ;SMTP = localhost
    SMTP = smtp.xs4all.nl
    ; http://php.net/smtp-port
    smtp_port = 25

    According to the xs4all tech desk website, these are the required settings:
    Instellingen e-mail via POP (instellingen = settings)
    Inkomende mailserver pop.xs4all.nl (poort 110) (inkomende = incoming)
    Uitgaande mailserver smtp.xs4all.nl (poort 25) (uitgaande = outgoing)

    Any idea why the application won't send the email to my xs4all address?

    Thanks for you help.
  2. allnodcoms

    allnodcoms It's My Birthday!

    Jun 30, 2007
    First off Andy, do you get "rslt = true" on both addresses? If you do I would suggest that it may be a server issue.

    Some Windows servers can get cross if "From:" is not a valid address, as they use it for ReplyTo (which has to be valid if present). I'd give that a go, and I'd also try setting the SMTP server back to localhost and see if that has any effect.

    Other than that it all looks OK.

  3. andynic

    andynic Thread Starter

    May 25, 2007
    Thanks for your reply, Danny.
    The rslt is "true" whether the code is as shown above or as revised below.
    I changed the command adding the -f parameter which I found under "additional parameters" on the php.net website in the mail function doc.
    $f = "-f $to";
    $rslt = mail($to, $subj, $msg, $hdr, $f);
    That works both with the php.ini SMTP parameter set to either localhost or as shown above. So I have left it as localhost.
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1061242