Jump to content

PHP Mailer

- - - - -

  • Please log in to reply
1 reply to this topic

#1
docmonkey

docmonkey

    Newbie

  • Members
  • PipPip
  • 10 posts
I've looked extensively on Google for this, and cannot find a single coherent answer...

When I am using PHP mailer class.. I get this error on trying to send the email.

There was an error in sending mail, please try again at a later time


Language string failed to load: from_failedjohn@market76.com

Here is the code in the script.

<?php

//change settings here

$your_email = "####@#######.com";

$your_smtp = "smtp.gmail.com";

$your_smtp_user = "####@#######.com";

$your_smtp_pass = "#######";

$your_website = "#######";



require("phpmailer/class.phpmailer.php");



//function to check properly formed email address

function isEmailValid($email)

{

  // checks proper syntax

  if( !preg_match( "/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/", $email))

  {

    return false;

  } 

  

  return true;

  

}



//get contact form details

$name = $_POST['name'];

$email = $_POST['email'];

$subject = $_POST['subject'];

$comments = $_POST['comments'];



//validate email address, if it is invalid, then returns error


if (!isEmailValid($email)) {

	die('Invalid email address');

}


//start phpmailer code 


$ip = $_SERVER["REMOTE_ADDR"];

$user_agent = $_SERVER['HTTP_USER_AGENT'];




$response="Date: " . date("d F, Y h:i:s A",time()+ 16 * 3600 - 600) ."\n" . "IP Address: $ip\nSubject: $subject\nUser-agent:$user_agent\nName: $name\nContents:\n$comments\n";

//mail("info@mypapit.net","Contact form fakapster",$response, $headers);


$mail = new PHPmailer();

$mail->SetLanguage("en", "/phpmailer/language/");

$mail->From = $your_email;

$mail->FromName = $your_website;

$mail->Host = $your_smtp;

$mail->Mailer   = "smtp";

$mail->Password = $your_smtp_pass;

$mail->Username = $your_smtp_user;

$mail->Subject = "$your_website feedback";

$mail->SMTPAuth  =  "true";


$mail->Body = $response;

$mail->AddAddress($your_email,"$your_website admin");

$mail->AddReplyTo($email,$name);



if (!$mail->Send()) {

echo "<p>There was an error in sending mail, please try again at a later time</p>";

echo "<p>".$mail->ErrorInfo."</p>";

} else {

	echo "<p>Thanks for your feedback, <em>$name</em>! We will contact you soon!</p>";

}


$mail->ClearAddresses();

$mail->ClearAttachments();


?>

Any ideas?? I'm on a local server, but since I'm using SMTP, shouldn't this work?

#2
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,299 posts
  • Location:Karlstad, Sweden
  • Programming Language:C, Java, C++, C#, PHP, JavaScript, Pascal
  • Learning:Java, C#
Seems that there is some kind of error in the script, as it says language string failed to load, and then, there is an email address. The PHPmailer class seems to be which is not working. something you have written? can we see the code?
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users