Results 1 to 3 of 3

Thread: PHP mail() not being received

  1. #1
    Registered
    Join Date
    Mar 2016
    Location
    Canada
    Posts
    1
    Rep Power
    0

    PHP mail() not being received

    When a customer places an order on my website, an e-mail is sent to them and to myself using PHP mail():

    Code:
    $headers = "MIME-Version: 1.0"."\r\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1"."\r\n";
    $headers .= "From: no-reply@mydomain.com";
    $message = ""; //some message
    $subject = ""; //some subject
    $email = ""; //some e-mail
    mail($email, $subject, $message, $headers);
    And looking at my php.ini file through PowWeb's website, things relevant to mail are as below:

    Code:
    [mail function]
    ; For Win32 only.
    ; http://php.net/smtp
    SMTP = mail.yourhostingaccount.com
    ; http://php.net/smtp-port
    smtp_port = 25
    
    ; For Win32 only.
    ; http://php.net/sendmail-from
    sendmail_from = wwwuser@cgi.yourhostingaccount.com
    
    ; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
    ; http://php.net/sendmail-path
    ;sendmail_path =
    
    ; Force the addition of the specified parameters to be passed as extra parameters
    ; to the sendmail binary. These parameters will always replace the value of
    ; the 5th parameter to mail(), even in safe mode.
    ;mail.force_extra_parameters =
    
    ; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename
    mail.add_x_header = On
    This was all working until a few hours ago. These lines confuse me:

    Code:
    SMTP = mail.yourhostingaccount.com
    sendmail_from = wwwuser@cgi.yourhostingaccount.com
    Previously when I received an e-mail through my site using mail(), it would always show up as "via yourhostingaccount.com". I noticed in my PowWeb Control Panel, these two things:

    Code:
    Incoming Mail Server:
    pop.mydomain.com
    
    Outgoing Mail Server:
    smtp.mydomain.com
    "mydomain.com" being my actual domain name, of course. Should these be in the php.ini somewhere?

    I thought perhaps there was an issue with the mail server, so I had tried sending and receiving e-mail from my e-mail addresses and it works, it's only through mail() that nothing goes through.

    Any ideas?

  2. #2
    Rick
    Join Date
    May 2002
    Location
    Minneapolis, MN
    Posts
    1,752
    Rep Power
    19
    It's extremely unlikely that the problem has anything to do with your php.ini file settings. There's probably a simple issue in your mail script. The code snippet you posted is fine, but it isn't enough to diagnose any problem here.

    You could try finding a simple Formmail script on your site just to insure that such scripts are working on your site.

    You could also add some temporary debugging code to your current script to insure that the parameters you're passing to the mail() function are what you intend them to be, as in:
    Code:
    mail($email, $subject, $message, $headers);
    
    echo ("\$email = $email<br>\n");
    echo ("\$subject= $subject<br>\n");
    echo ("\$message= $message<br>\n");
    echo ("\$headers= $headers<br>\n");
    die;
    This will let you know (a) that the script actually gets executed to completion, and (b) what the mail() function is using. Good luck!
    Rick Trethewey

  3. #3
    Custom User Title entrecon's Avatar
    Join Date
    Aug 2006
    Location
    Michigan
    Posts
    2,742
    Rep Power
    16
    Sorry for the late response, but the other thing you can do is look at the script logs. You should be able to find it in OPS. I will usually clear my log and then do the process that is broken and refresh the log to see what new items, if any, have popped up.
    ________________________________
    Find me on twitter: @entrecon

Posting Permissions

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