Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Banned
    Join Date
    Mar 2007
    Posts
    1,523
    Thanks
    116
    Thanked 0 Times in 0 Posts

    mail script sends mail when testing locally but not live

    hi,

    When i was testing my site, the send mail code was working fine, now I have uploaded it to my live server, I'm not recieving any email and there are no errors?!

    here is the code:

    PHP Code:
            $body 'Someone with the email: '.$emailaddress.' voted for: '.$opt[$z];

     
    $to "jarv@email.co.uk";
     
    $subject "New vote submitted";
     if (
    mail($to$subject$body)) {
       echo(
    "<p>Message successfully sent!</p>");
      } else {
       echo(
    "<p>Message delivery failed…</p>");
      } 

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Does it say the message is sent? If so, the mail is queued and this is an issue with your smtp server, not a PHP one.
    If it said it failed, than you likely haven't configured the smtp options in the php.ini. Either configure them there, or provide the configuration options as the fifth argument in the mail call.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #3
    Banned
    Join Date
    Mar 2007
    Posts
    1,523
    Thanks
    116
    Thanked 0 Times in 0 Posts
    it says Message sent!

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Then you can take a dive into the sendmail logs on the machine. This isn't directly a PHP issue, so you'll need to find out what's wrong with the sendmail.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #5
    New Coder
    Join Date
    Dec 2012
    Location
    USA
    Posts
    82
    Thanks
    3
    Thanked 17 Times in 17 Posts
    Just adding an option to the one Fou-Lu has stated,

    Did you check your spam folder?

  • #6
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,361
    Thanks
    61
    Thanked 530 Times in 517 Posts
    Also, I've known PHP to pass mail to sendmail but sendmail doesn't actually send it due to the 4pth parameter being missing in the call to mail().

    @jarv what this means is that you need to set an additional 'from' field in the 4th parameter. PHP.net will show you how to do this.

    As the others have said though, you also need to check your logs if you have access (not everyone does) and any spam folders etc.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!


  •  

    Posting Permissions

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