Php mailer working problem


#1

Dear sir…
Please inform me that I can use phpmailer with gmail SMTP on a free account…immediate reply will be highly appreciated


#2

Yes, you can use phpmail with gmail SMTP


#3

But when I add php mailer into the page…it’s perfectly working fine in the local server…but when I upload to server…the page containing the code didn’t show it’s self


#4

What page are you referring to?

Can you access it by removing https and trying http if it initially shows https?


#5

It’s not working…but the same code perfectly work in local hostil…iam using phpmailer


#6

can you show us the code, so we could assist you better?


#7
<?php

require_once("mail/class.PHPMailer.php");

 

function reg($email,$rand)

{             

$mail = new PHPMailer();

 

//$mail->IsSMTP();                                      // set mailer to use SMTP

$mail->SMTPDebug = 0;  // debugging: 1 = errors and messages, 2 = messages only

                $mail->SMTPAuth = true;  // authentication enabled

                $mail->SMTPSecure = 'TLS'; // secure transfer enabled REQUIRED for GMail

                $mail->Host = 'smtp.gmail.com';

                $mail->Port = 25;      // turn on SMTP authentication

$mail->Username = "abdulsatharpss";  // SMTP username

$mail->Password = "#######"; // SMTP password

 

$mail->From = "abdulsatharpss@gmail.com";

$mail->FromName = "Palakkad Pravasi Peoples Forum";

$mail->AddAddress($email);

/*$mail->AddAddress("ellen@example.com");    */              // name is optional

$mail->AddReplyTo("abdulsatharpss@gmail.com", "Information");

 

/*$mail->WordWrap = 50;                                 // set word wrap to 50 characters

$mail->AddAttachment("/var/tmp/file.tar.gz");         // add attachments

$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); */   // optional name

$mail->IsHTML(true);                                  // set email format to HTML

$message = '<html><body>';

$message.='<div style="width:550px; background-color:#CC6600; padding:15px; font-weight:bold;">';

$message.='Confirm your registration with us';

$message.='</div>';

$message.='<div style="font-family: Arial;">Thanks for joining with us.<br/>';

$message.='click on the below link in your verification mail id to verify your account ';

$message.="<a href='http://localhost/user-confirmation.php?email=$email&confirmation_code=$rand'>click</a>";

$message.='</div>';

$message.='</body></html>';

 

$mail->Subject = "Regsitration confirmation";

$mail->Body    = $message;

$mail->AltBody = "This is the body in plain text for non-HTML mail clients";

 

if(!$mail->Send())

{

   echo "Message could not be sent. <p>";

   echo "Mailer Error: " . $mail->ErrorInfo;

   exit;

}

 

$msg="Confirmation msg hase send to ur mail id.";

return $msg;

}

?>

#8

Your port seems wrong for SMTP although I could be wrong?


#9

Before I checked all the port’s …not working

Is there any option to enable SMTP mail sending ini php


#10

It will be enabled what errors do you get?


#11

No error msgs…
The same code used in local host…on server it shows blank page…


#12

So the script doesn’t even come up at all?
Which page is this hosted at?


#13

https://pppf.000webhostapp.com/register.php


#14

So is that the error you get 500? Or does the page sometimes load or what?


#15

With the php mailer code …it will not work…if i remove that code. The other parts works…
With the mail code the page does not show anything


#16

What does it look like on localhost when you load it?

Can you zip it and upload to your site and link it here just so I can load onto my free hosting and premium to see if it appears?


#18

Any update sir???please help me


#19

I tried it both on free and premium and both encountered 500 error I have not yet investigated the cause at the moment but I have a working sendmail script on both free and premium so would suggest the issue is with the code obviously.


#20

Can u upload the working code ???


#21

[code]<?php
//if “email” variable is filled out, send email
if (isset($_REQUEST[‘email’])) {

//Email information
$admin_email = "someone@example.com";
$email = $_REQUEST[‘email’];
$subject = $_REQUEST[‘subject’];
$comment = $_REQUEST[‘comment’];

//send email
mail($admin_email, “$subject”, $comment, “From:” . $email);

//Email response
echo “Thank you for contacting us!”;
}

//if “email” variable is not filled out, display the form
else {
?>

Email:
Subject:
Message:

<?php } ?>[/code]