www.webdeveloper.com
Results 1 to 6 of 6

Thread: [RESOLVED] Problems with mail()

  1. #1
    Join Date
    Aug 2010
    Location
    Ohio
    Posts
    136

    resolved [RESOLVED] Problems with mail()

    Ok so I spent a short time making this survey, and setting up a form to handle sending invites for the survey out to people (to be used in house). During production it was working fine, now the emails are not showing up in our in-boxes. The mail function is still returning true, so I'm unsure of why its not showing up. None of the code has changed, and our development environment is on the exact same server as our production environment, so ini settings are all the same as well. Below is a snippet of the code, and attached is the entire file.

    PHP Code:
       // Constant email settings.
       
    $sub '--- Satisfaction Survey Invite';
       
    $headers 'MIME-Version: 1.0'PHP_EOL;
       
    $headers .= 'Content-type: text/html; charset=iso-8859-1'PHP_EOL;
       
    $headers .= 'FROM: ---@---.com'PHP_EOL;
       
       
    // Base SQL for multiple insert
       
    $sql 'INSERT INTO survey_invites (id_invite,invite_email,invite_token) VALUES ';
       
       foreach( 
    $emails as $info ) {
          
    $token saltyhash($info['email']);
          
          
    // Send mail message to each recipient
          
    $to $info['email'];
          
    $msg buildmsg($info['name'],$token,$info['type']);
          if( 
    mail($to,$sub,$msg,$headers) )
             
    $content .= 'Message to '$info['name'] .' sent successfully.<br />';
          else
             
    $content .= 'Message to '$info['name'] .' failed to send.<br />';
          
          
    // Build SQL to insert email/token for validation later.
          
    $sql .= '(NULL,\''$info['email'] .'\',\''$token .'\'),';
       }
       
    $sql substr($sql,0,-1);
       if( 
    $db->query($sql) )
          
    $content .= 'Emails and tokens successfully stored in the database.'
    As I said, it was working perfectly while I was testing it, now its like the emails aren't sending, or for some reason just aren't making it to our inbox (yes we've checked our spam box as well)

    *Note: I have removed identifying information.
    Attached Files Attached Files

  2. #2
    Join Date
    Mar 2009
    Posts
    452
    i too got the same problem few months ago... it was on a hosting server which did not support From header so when i removed From header it worked as expected.

    Maybe helpful to you...

  3. #3
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    18,922
    Is the "from" email address a valid email on the host where the script is running? (Many hosts are configured to only allow that so as to prevent spammers from using the host to relay email.) If this is the case, set the "From:' header to a valid email address for that host, and then add a "Reply-To:" header with the desired email.

    It probably does not matter, but the "FROM:" header should be "From:".
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  4. #4
    Join Date
    Aug 2010
    Location
    Ohio
    Posts
    136
    Well according to php.net headers shouldn't be case sensitive, but I'll give it a try. And like I said it was working in the development sub-folder which would be domain.com/dev/survey instead of domain.com/survey so the fact that it did work is what bothers me.
    Anyway it seems to be working but on a delay of some sort (takes 1-2 hours to show up in the mailbox). Luckily, as long as it works its good to go for now. I wish my server supported pear::mail_mime

  5. #5
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    18,922
    Quote Originally Posted by NoasIT View Post
    ... I wish my server supported pear::mail_mime
    You might consider using the PHPMailer class, which provides a lot control and flexibility to sending emails. Also, it is possible to install PEAR packages yourself within your site's web directories without the full PEAR installation, it's just a lot more fiddly, as you have to make sure all dependencies are uploaded and the include_path is adjusted as needed (making PHPMailer look like a better deal ).
    Last edited by NogDog; 06-16-2011 at 02:51 PM.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  6. #6
    Join Date
    Aug 2010
    Location
    Ohio
    Posts
    136
    Thanks, I'll have a look at it Monday when I'm back in the office. For now sending invites with an hour or two delay isn't that big of a deal, but will definitely check it out as installing pear in a web accessible folder doesn't seem "ideal" to me.

Thread Information

Users Browsing this Thread

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

Posting Permissions

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



Recent Articles