Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-25-2013, 04:12 PM   PM User | #1
jarv
Banned

 
Join Date: Mar 2007
Posts: 1,523
Thanks: 116
Thanked 0 Times in 0 Posts
jarv can only hope to improve
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>");
  } 
jarv is offline   Reply With Quote
Old 01-25-2013, 04:17 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,650
Thanks: 4
Thanked 2,451 Times in 2,420 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
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.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Fou-Lu is offline   Reply With Quote
Old 01-25-2013, 04:18 PM   PM User | #3
jarv
Banned

 
Join Date: Mar 2007
Posts: 1,523
Thanks: 116
Thanked 0 Times in 0 Posts
jarv can only hope to improve
it says Message sent!
jarv is offline   Reply With Quote
Old 01-25-2013, 04:24 PM   PM User | #4
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,650
Thanks: 4
Thanked 2,451 Times in 2,420 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
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.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Fou-Lu is offline   Reply With Quote
Old 01-25-2013, 04:27 PM   PM User | #5
TFlan
New Coder

 
Join Date: Dec 2012
Location: USA
Posts: 82
Thanks: 3
Thanked 17 Times in 17 Posts
TFlan is an unknown quantity at this point
Just adding an option to the one Fou-Lu has stated,

Did you check your spam folder?
TFlan is offline   Reply With Quote
Old 01-25-2013, 04:55 PM   PM User | #6
tangoforce
Senior Coder

 
tangoforce's Avatar
 
Join Date: Feb 2011
Location: Your Monitor
Posts: 3,507
Thanks: 45
Thanked 439 Times in 428 Posts
tangoforce will become famous soon enoughtangoforce will become famous soon enough
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.
__________________
Please wrap your code in [php] tags. It is a sticky topic and it HELPS us to HELP YOU!
TIP: Coding styles and $end errors :::::::::: TIP: Warning: Cannot modify header information - headers already sent :::::::::: TIP: Quotes / Parse error: syntax error, unexpected T_..
PHP Code:
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value. 
Explanation: The IE if(isset($_POST['submit'])) bug explained.
tangoforce is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:16 PM.


Advertisement
Log in to turn off these ads.