0

I am stuck with this issue. I tried to search it, but no help. I have a very small application running on my local WAMP. I have tested my application on a WAMP server, and mailing service works perfectly. My WAMP has PHP 5.4, but when I deployed the same code on a hosting server(Network Solutions with PHP 5.3.27) it is not working. Below is my code:

<?php
require 'PHPMailerAutoload.php';
/*
    other code;
*/
//Mailing settings
$mail = new PHPMailer;
$mail->isSMTP();                                      
$mail->Host = 'smtp.server_name.net';  
$mail->SMTPAuth = true;                 
$mail->Username = ' admin_user_name@server_name.net';                 
$mail->Password = 'password';                           
$mail->SMTPDebug = 1;
$mail->From = 'from_address@server_name.net';
$mail->FromName = 'from_name';
$mail->addAddress('receiver_add@abc.com', 'Receiver');     
$mail->addCC('cc_address@abc.com','XYZ');
$mail->WordWrap = 50;                                 
$mail->Subject = 'Subject_Was_Not_Long';
$body=" ABCD BODY.\n";
$mail->Body    = $body;
if(!$mail->send()) {
    header('Location: Same_File.php?registered=false');
} else {
    header('Location: Same_File.php?registered=true');
}
?>

I am not sure what I have to do, because I am not able to access the PHP config as well. Please help!

Extra bit of info: Configuration Hosting Server My PC System Linux Windows Server API CGI/Fast CGI Apache Handler 2.0 Virtual Directory Support Disabled Enabled Thread Saftey Disabled Enabled

Thank You...

AKSH
  • 19
  • 1
  • 6
  • _it is not working_ - you get any error? – Black Sheep Jun 25 '14 at 11:56
  • Sounds like some required PHP extension is not enabled in the ini. Since you don't have access to it, I assume you're on a shared host? Some providers allow to create a own php ini file which you place in the main folder of your project on the server where the settings should take effect... Did you contact the hosting provider with your issue yet? BTW: Compare your local server php settings with your live one by using e.g. `get_loaded_extensions()` or `phpinfo()`. – Markus Hofmann Jun 25 '14 at 11:58
  • I used phpinfo() and found that opensll is enabled, if there is anything else I need I will compare. I will attach the php config to this thread. – AKSH Jun 25 '14 at 12:09
  • The server is shared, and I have communicated this issue to my manager, she said she will definitely talk to the hosting company. But I would like learn if I have to configure something specially in PHP.INI – AKSH Jun 25 '14 at 12:17
  • @aldanux Thank You, I am not getting any error, Simply mail->send() returns false. How should I enable debugging through my page, as I am not able to access the main php.ini – AKSH Jun 25 '14 at 12:27
  • @AKSH - To see the error try with: `$mail->ErrorInfo` – Black Sheep Jun 25 '14 at 12:30
  • Okay! I will do it right away. Thanks @aldanux – AKSH Jun 25 '14 at 12:31
  • Turn up SMTP debugging: `$mail->SMTPDebug = 3;` – Synchro Jun 25 '14 at 13:04
  • @AKSH Did you get on solving the problem? Let us know what the hosting provider responded. – Markus Hofmann Jun 25 '14 at 20:24
  • 1
    @MarkusHofmann Definitely; Today I am not working, I will talk to them on Monday: I will keep you posted: Thanks – AKSH Jun 26 '14 at 01:38
  • @aldanux I am not really experienced with PHP, I have put the code as you both suggested but how I am supposed to check the error or issue??? – AKSH Jun 27 '14 at 00:07
  • I tried this link as well http://stackoverflow.com/questions/2386544/error-handling-with-phpmailer But I am not able to see any error. I am not understanding what is happening. – AKSH Jun 27 '14 at 12:45

1 Answers1

1

Had the same problem just now. The problem is fixed in the current GitHub version of PHPMailer. PHPMailer initially checks for version '5.0.0', but it contains the array syntax [] which is only active in version 5.4. If you replace all the [] in the PHPMailer classes with array(), it works.

mch
  • 1,259
  • 15
  • 23