My codes run successfully but not send the email, HELP ME!

Swift Mailer is a fantastic library for sending email with php. Discuss this library or ask any questions about it here.

Moderators: Chris Corbyn, General Moderators

My codes run successfully but not send the email, HELP ME!

Postby rourou » Tue Jul 07, 2009 1:59 pm

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
rourou
Forum Newbie
 
Posts: 1
Joined: Tue Jul 07, 2009 1:25 pm

Re: My codes run successfully but not send the email, HELP ME!

Postby Adonis » Tue Jul 21, 2009 12:36 pm

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.
Adonis
Forum Newbie
 
Posts: 1
Joined: Tue Jul 21, 2009 12:29 pm

Re: My codes run successfully but not send the email, HELP ME!

Postby nanonano » Mon Aug 17, 2009 9:02 pm

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
nanonano
Forum Newbie
 
Posts: 1
Joined: Mon Aug 17, 2009 9:00 pm


Return to Swift Mailer

Who is online

Users browsing this forum: gqapqedmaz and 2 guests

cron