PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Fri Nov 28, 2014 10:29 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Tue Jul 07, 2009 1:59 pm 
Offline
Forum Newbie

Joined: Tue Jul 07, 2009 1:25 pm
Posts: 1
My codes are here:
Syntax: [ Download ] [ Hide ]
 
<?php
require_once "./lib/swift_required.php";
 
function sendMail()
{
    //Create the Transport
    $transport = Swift_SmtpTransport::newInstance("localhost", 25);
 
    //Create the Mailer using your created Transport
    $mailer = Swift_Mailer::newInstance($transport);
 
    //Create a message
    $message = Swift_Message::newInstance();
 
    $message->setFrom("yzhang03@students.poly.edu");
    $message->setTo("yzhang03@students.poly.edu");
 
    $message->setSubject("This is a subject");
    $message->setBody("This is mail body");
 
    echo $message->toString();
   
    try
    {
        $result = $mailer->send($message);
        echo $result;
    }
    catch (Swift_ConnectionException $e)
    {
        echo 'There was a problem communicating with SMTP: ' . $e->getMessage();
    }
   
 
    if ($mailer->send($message))
    {
    echo "Message sent!";
    }
    else
    {
     echo "Message could not be sent.";
    }
}
    sendMail();
?>
 
 


It's result like this:
Message-ID: <1246992745.4a53996908c93@swift.generated>
Date: Tue, 07 Jul 2009 11:52:25 -0700
Subject: This is a subject
From: yzhang03@students.poly.edu
To: yzhang03@students.poly.edu
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
This is mail body Message sent!


But why actually I didn't get the message?
I have tried different kind of emails,like yahoo, gmail...they all doesn't work :cry:

PS: I do have try to use Linux command mail to send the email, that success.

Thanks a lot for any help!!! :P


Top
 Profile  
 
PostPosted: Tue Jul 21, 2009 12:36 pm 
Offline
Forum Newbie

Joined: Tue Jul 21, 2009 12:29 pm
Posts: 1
I would like to know more about this also because I have been having some trouble as well. My problem is that it works great on my local machine but when I upload the code to the site it gives me a syntax error unexpected T_CLASS on line 28 of the Swift.php file.


Top
 Profile  
 
PostPosted: Mon Aug 17, 2009 9:02 pm 
Offline
Forum Newbie

Joined: Mon Aug 17, 2009 9:00 pm
Posts: 1
I had a similar problem.
(works perfect on local machine but doesn't work on live website)

I was using WAMP with php 5 and live website PHP 4,
then I upgraded live to php5
now I have no error message but I don't receive the emails neither...

could it be something in phpconfig?

any help will be very appreciated


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group