Help on gmail SMTP connection
Posted: Wed May 07, 2008 5:17 am
hello just step into the swift mailer universe.trying to send an email from my Xampp 1.6.0a apache server on localhost.the php version is 5.2.1.I've seen the documentation online and opted to use the gmail SMTP server(before i uploap to my host and set the proper smtp server).But i'm having an issue.First of all i can see the function setUsername, i'm seeing setOption and setDomain.How do i make it work?Is the problem from the facti'm on localhost? Here is the code of my sendmail function
i'm seeing this error each time i launch it
Code: Select all
<?php
include_once('swift/Swift.php');
include_once('swift/Swift/Connection/SMTP.php');
function sendEmail($message,$to)
{
$smtp =& new Swift(new Swift_Connection_SMTP("smtp.gmail.com",Swift_Connection_SMTP::PORT_SECURE,Swift_Connection_SMTP::ENC_TLS));
$stmp->setUsername("myusername");
$smtp->setpassword("mypass");
$swift =& new Swift($smtp);
$mes =& new Swift_Message("Voucher from txtBuddy",$message,"test/html");
if($swift->send($mes,$to,"some@trueema.com"))
{
return "ok";
}
else
{
die("We are unable to send you the mail for some technical problem");
}
}
$tosend = '<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Payed voucher number from txtBuddy</title>
</head>
<body style="height:100%;min-height:100%;">
<center>
<div style="width:800px;position:relative;_height:100%;min-height:100%">
<div style="width:600px;height:200px;margin:0 200px 0 200px auto">
<div style="background-color:#4A7CAE;color:#FFFFFF;font-family:Verdana, Arial, Helvetica, sans-serif;font-weight:bold">
TxtBuddy credit voucher
</div>
<div style="background-color:#E4EFF8;height:180px;color:#F38F5F;">
Text buddy is glad to send you your text voucher
<b style="color:#003399">'. $voucheritself.' </b>
suscribed through i-wallet. This voucher is valid to send only
'. $smsbought.' sms bought from txtBuddy.For sending text message click
<a href="#">Here</a> to send your first text sms with TxtBuddy
</div>
</div>
</div>
</center>
</body>
</html>';
//pass the variable got from the list function on $voucherdetails which hold the values of the retreiveVoucherDetails call
$mailstatus=$h->sendEmail($tosend,$mail);
if($mailstatus == 'ok')
{
?>
<div>Dear customer a Email has been sent to your mail box with the voucher detail</div>
<?php
}
?>
i'm seeing this error each time i launch it
Fatal error: Call to a member function setUsername() on a non-object in C:\Program Files\xampp\htdocs\servTxtBuddy\callhandler.class.php on line 83