Fatal error occuerred ?
Posted: Tue Mar 04, 2008 9:35 am
Hello,
I just ran some tests and keep getting fatal errors.
This one:
Fatal error: Uncaught exception 'Swift_ConnectionException' with message 'The SMTP connection failed to start [tls://smtp.gmail.com:465]: fsockopen returned Error Number 110 and Error String 'Connection timed out'' in /home/letsget/public_html/swift_lib/Swift/Connection/SMTP.php:309 Stack trace: #0 /home/letsget/public_html/swift_lib/Swift.php(216): Swift_Connection_SMTP->start() #1 /home/letsget/public_html/swift_lib/Swift.php(101): Swift->connect() #2 /home/letsget/public_html/b_email_act.php(94): Swift->__construct(Object(Swift_Connection_SMTP)) #3 /home/letsget/public_html/index.php(229): require_once('/home/letsget/p...') #4 {main} thrown in /home/letsget/public_html/swift_lib/Swift/Connection/SMTP.php on line 309
I am running:Swift-3.3.2-php5
and the server has php 5.2
my script is:
The $header variable is set up but the headers are not used anywhere in the swift.
I should probably include a text verion of the message - but I am not sure how to implement that yet.
My question is - "what have I done wrong, why is it failing" ?
I hope that its a pretty obvious reason.
Thanks
I just ran some tests and keep getting fatal errors.
This one:
Fatal error: Uncaught exception 'Swift_ConnectionException' with message 'The SMTP connection failed to start [tls://smtp.gmail.com:465]: fsockopen returned Error Number 110 and Error String 'Connection timed out'' in /home/letsget/public_html/swift_lib/Swift/Connection/SMTP.php:309 Stack trace: #0 /home/letsget/public_html/swift_lib/Swift.php(216): Swift_Connection_SMTP->start() #1 /home/letsget/public_html/swift_lib/Swift.php(101): Swift->connect() #2 /home/letsget/public_html/b_email_act.php(94): Swift->__construct(Object(Swift_Connection_SMTP)) #3 /home/letsget/public_html/index.php(229): require_once('/home/letsget/p...') #4 {main} thrown in /home/letsget/public_html/swift_lib/Swift/Connection/SMTP.php on line 309
I am running:Swift-3.3.2-php5
and the server has php 5.2
my script is:
Code: Select all
<?php
/*
* emailler.php
*
*
* send WAITING CONFIRMATION email
*/
/*
* make MESSAGE
*/
require_once("my_functions.php");
$messageX = "
<html>
<head>
<title>www.Lets-Get-Started.net</title>
</head>
<body>
<div style = '
width:600px;
background-color:white;
font-family:Tahoma, Tunga, sans-serif;
font-size:14;
text-align:left;
font-weight:normal;
padding:1px;
margin:1px;
'>
<p>
<br>
<center><b>Free Entry to the Lets-Get-Started.net Membership site - Confirmation.</b></center>
<br><br>
Dear $N_contact,
<br><br>
Welcome aboard!
<br><br>
Your email and password are recorderd as follows:<br>
Email: $N_email <br>
Password : $N_pass<br>
<br>
Please record your password as you will need it when entering the site.
<br><br>
Please click on the link below to confirm your free entrance into 'Lets-Get-Started'.
<br><br>
You will be taken directly to the introduction page.
<br><br>
<a href=\"http://www.lets-get-started.net/do_it.php?client=$N_email\">Confirm and enter site.</a>
<br><br>
See you there!
<br><br>
******************<br>
<br><br>
</p>
</div>
</body>
</html>
";
// Set up correct headers
$to = $N_email;
$from="Dave@lets-get-started.net";
$name="Dave";
$headers ="MIME-Version:1.0\r\n";
$headers .="content-type:text/html; Charset=iso-8859-1\r\n";
$headers .= "From: " . "$name" . "<" . "$from" . ">\n";
$headers .= "Return-Path: <" . "$to" . ">\n";
$headers .= "Error-To: <" . "$to" . ">\n";
$headers .= "X-Sender: <" . "$to" . ">\n";
$headers .= "X-Mailer: PHP v".phpversion()."\n";
// subject
$subject = "As Promised ...Your Free Access to LETS GET STARTED.";
$subject= nl2br($subject);
// $messageX = "this is a temporary test message";
$message=$messageX;
$message=nl2br($message);
require_once "swift_lib/Swift.php";
require_once "swift_lib/Swift/Connection/SMTP.php";
//Create a Swift instance and connect to Gmail (PHP5)
$swift = new Swift(new Swift_Connection_SMTP(
"smtp.gmail.com", Swift_Connection_SMTP::PORT_SECURE, Swift_Connection_SMTP::ENC_TLS));
$smtp->setUsername('lets.get.started.net@gmail.com');
$smtp->setPassword('gpassword');
$swift =& new Swift($smtp);
//Create the sender from the details we've been given
$sender =& new Swift_Address($email, $from);
//Create the message to send
$message =& new Swift_Message($subject);
$message->attach(new Swift_Message_Part($message, "text/html"));
//Try sending the email
$sent = $swift->send($message, "$to", $sender);
//Disconnect from SMTP, we're done
$swift->disconnect();
if ($sent)
{
echo " GREAT IT WORKED !!! ";
exit();
}
else
{
echo " OOPS WE HAVE A PROBLEM !!! ";
exit();
}
/* ALL BELOW IS COMMENTED OUT - SO IGNORE !!
* OLD EMAIL code
// mail($to, $subject, $message, $headers) ;
if (mail($to, $subject, $message, $headers) == false)
{
echo "Email failed";
}
echo "To: $to, <br>Subject: $subject, <br>Headers: $headers, <br>Message: $message";
$res = mail("yukseklikler@hotmail.com", "Test php mailer for Lets-Get.net", "Hi,
this message proves that php email scripts are working on the domain Lets-Get.net", "From: root@lets-get-started.net", "root@lets-get-started.net");
if($res == 1){
echo "email sent successfully, check email to make sure it was recieved."; }
*/
?>
I should probably include a text verion of the message - but I am not sure how to implement that yet.
My question is - "what have I done wrong, why is it failing" ?
I hope that its a pretty obvious reason.
Thanks