0

I have this error message. Could you please help me ?

My email.php;

<?php

header('Content-Type: text/html; charset=utf-8');
require 'PHPMailerAutoload.php';
$phpmailer = new PHPMailer;
$phpmailer->isSMTP();
$phpmailer->Host = 'mail.coffeewritingcontent.com';
$phpmailer->SMTPAuth = true;
$phpmailer->Username = 'iletisim@coffeewritingcontent.com';
$phpmailer->Password = 'mypassword';
$phpmailer->SMTPSecure = 'tls';
$phpmailer->Port = '587';
$phpmailer->From = 'iletisim@coffeewritingcontent.com';
$phpmailer->FromName = $_POST['name'];
$phpmailer->AddReplyTo($_POST['email'], $_POST['name']);
$phpmailer->addAddress('iletisim@coffeewritingcontent.com', 'İletişim Formu');
$phpmailer->isHTML(true);
$phpmailer->Subject = 'İletisim formu mesajı';
$phpmailer->Body    = "isim: " . $_POST['name'] . "\r\n\r\nMesaj: " . stripslashes($_POST['message']);
$phpmailer->CharSet = 'UTF-8';
$phpmailer->SMTPDebug = 4;
if(!$phpmailer->send()) {
   echo 'Mail gonderilemedi. Hata: ' . $phpmailer->ErrorInfo;
   exit;
}

echo 'Mail gonderildi.';

?>

my error;

2016-03-26 21:52:59 Connection: opening to mail.coffeewritingcontent.com:587, timeout=10, options=array ( ) 2016-03-26 21:53:09 SMTP ERROR: Failed to connect to server: Connection timed out (110) Mail gonderilemedi. Error: Language string failed to load: connect_host

erenesto
  • 197
  • 1
  • 11

2 Answers2

0

Plase try this code. I'm using now in a server with GoDaddy and everything going good. Please make sure to require the php library with a require_once instance

            $mail = new PHPMailer;
            $mail->isSMTP();                                      // Set mailer to use SMTP
            $mail->Host = 'localhost';  // Specify main and backup SMTP servers
            $mail->SMTPAuth = true;                               // Enable SMTP authentication
            $mail->Username = 'mymail@mydomain.com';                 // SMTP username
            $mail->Password = 'password';                           // SMTP password
            $mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
            $mail->Port = 25;                                    // TCP port to connect to
            $mail->setFrom('mymail@mydomain.com', 'Name');
            $mail->addAddress($email); 
            $mail->isHTML(true); 

            $mail->setLanguage('es');
            $mail->CharSet = 'UTF-8';   

            $mail->Subject = 'Welcome!';

            $mail->Body  = 'This is a messagge test!';
            if ( !$mail->send() ) :
                echo 'Error while sending mail.';
             else :
                echo 'The messagge send correctly';
            endif;
Fernando Torres
  • 460
  • 7
  • 24
-1

Did you create an instant of $phpmailer before do all those code? Probably you have to do it. So, if you already do that, please review your file PHPMailerAutoload.php and make sure that you have into your folder all and complety files that phpmailer provide us after the download content. I will show you an example for a correctly code that sends email from phpmailer.

require_once('../class.phpmailer.php');

$mail             = new PHPMailer(); // defaults to using php "mail()"

$body             = file_get_contents('contents.html');
$body             = eregi_replace("[\]",'',$body);

$mail->AddReplyTo("name@yourdomain.com","First Last");

$mail->SetFrom('name@yourdomain.com', 'First Last');

$mail->AddReplyTo("name@yourdomain.com","First Last");

$address = "whoto@otherdomain.com";
$mail->AddAddress($address, "John Doe");

$mail->Subject    = "PHPMailer Test Subject via mail(), basic";

$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test

$mail->MsgHTML($body);

$mail->AddAttachment("images/phpmailer.gif");      // attachment
$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment

if(!$mail->Send()) {
  echo "Mailer Error: " . $mail->ErrorInfo;
} else {
  echo "Message sent!";
}

Please make sure too that you are sending emails from a server already upload. If you are using virtual serves like XAMPP, review this page for enable the smtp configuration: How to configure XAMPP to send mail from localhost?

Greetings.

Community
  • 1
  • 1
Fernando Torres
  • 460
  • 7
  • 24
  • Fernando, I have this files from phpmailer zip inside my folder already. PHPMailerAutoload.php class.phpmailer.php class.pop3.php class.smtp.php But it's not working as i said and i am having that error as i wrote. i am using my hosting service, i dont use xamp server. I hope you can help me. – erenesto Mar 27 '16 at 00:32
  • You've posted an obsolete example and are using an old version of PHPMailer. Don't. – Synchro Mar 27 '16 at 08:14