0

On my website I have a simple contact form but I can't figure out why I can't send email.

HTML:

<form id="contactForm" method="post"  action="js/sendmail.php" >
  <fieldset>
     <p><label for="name" class="label">Name*:</label>
     <input type="text" name="name" id="Text1" class="input required"  />                                        
     </p>
     <p><label for="email" class="label">Email*: </label>
      <input type="email" name="email" id="contact_email" class="input email required"  />  
      <span class="input_feedback"></span>                                      
     </p>          
     <p>
      <label class="label">Your message*: </label>
      <textarea class="textarea required" name="message" rows="10" cols="50"  ></textarea>
     </p>
     <p class="submitButtons">
      <input type="submit" value="Send email" id="senEmail"    class="button"/>   
     </p>                      
  </fieldset>
</form>

PHP:

<?php
include('class.phpmailer.php');
include("class.smtp.php"); 
session_set_cookie_params('3600'); // 1 hour
session_start();
$mail->SMTPSecure = "ssl"; 
$mail->SMTPKeepAlive = true;  
$mail->Mailer = "smtp"; 
$mail = new PHPMailer(); // create a new object
$mail->SMTPDebug =2;
$mail->IsSMTP(); // send via SMTP
$mail ->Host = 'mrvnet.kundenserver.de';       
$mail->Port= 465;
$mail->SMTPAuth = true;
$mail->Username = 'info@brightongatwicktransfer.com';
$mail->Password = '******';
$mail->SetFrom('myName@yahoo.com');
$mail->Subject = "Test";
$mail->Body = "Something";
$mail->AddAddress('info@brightongatwicktransfer.com');
if(!$mail->Send())
{ echo "Mailer Error: " . $mail->ErrorInfo;}
else
{ echo "Message has been sent";}
?>

I tried with 'ssl' and 'tls' but no results.

Host company said the host is correct and asked me to try with 587 and 25 ports but I always received the same error:

2013-12-04 11:40:00 SMTP ERROR: Failed to connect to server: A connection attempt
failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. (10060) SMTP connect() failed. Mailer Error: SMTP connect() failed.

Damon
  • 3,004
  • 7
  • 24
  • 28

1 Answers1

0

Not a PHP coder but here:

$mail->SMTPSecure = "ssl"; 
$mail->SMTPKeepAlive = true;  
$mail->Mailer = "smtp"; 
$mail = new PHPMailer(); // create a new object

You're allocating the object after you use it, this is invalid, you should allocate it first:

$mail = new PHPMailer(); // create a new object
$mail->SMTPSecure = "ssl"; 
$mail->SMTPKeepAlive = true;  
$mail->Mailer = "smtp"; 
  • Thanks but now i got:2013-12-04 12:41:02 SMTP ERROR: Failed to connect to server: Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP? (4104) SMTP connect() failed. Mailer Error: SMTP connect() failed. – Alina.Basa Dec 04 '13 at 12:41
  • If you're windows, check this out (http://stackoverflow.com/questions/1705856/socket-transport-ssl-in-php-not-enabled), if Linux, http://www.simplemachines.org/community/index.php?topic=310264.0 –  Dec 04 '13 at 12:46
  • Thanks, just received an email from my hosting 'smtp sending via php script is not possible in our shared hosting is not possible due to limitation of the its fixed settings. We highly suggest you use either using php mail or asp mail' – Alina.Basa Dec 04 '13 at 13:43