Page 1 of 1

Newb problem sending mail from form

Posted: Tue May 13, 2008 7:22 pm
by hooly69
Hi all,
trying to send a basic email from a web feedback document and getting an error on the swift send part.
the swift_mail.php looks like this.

<?php
require_once "/homepages/3/.../htdocs/swift/Swift.php";
require_once "/homepages/3/.../htdocs/swift/Swift/Connection/NativeMail.php";

$to_email = 'myemail@yahoo.com';
$subject = 'subject';
$text = 'From: ' . $_REQUEST['name'] . "\n\n" . $_REQUEST['data'];
$from_email = $_REQUEST['email'];

//Create the message
$message =& new Swift_Message($subject, $text);

//Now send it
$swift->send($message, $from_email, $to_email);

?>

Once the form is submitted I get
Fatal error: Call to a member function send() on a non-object in /homepages/3/d244140422/htdocs/swift_mail.php on line 14
The 'name' 'data' and 'email' are all pulled from the form and are valid.
It worked before with mail() but the messages kept going to junk, I was told by a friend to try swiftmailer.
Any ides where to look, have looked through the forums but i'm new to this and can't see an answer.
Thanks in advance.

Re: Newb problem sending mail from form

Posted: Tue May 13, 2008 10:08 pm
by Chris Corbyn
Please read the manual, starting with the tutorials:

http://swiftmailer.org/wikidocs

You've missed a vital step which is shown on almost every page in the documentation ;)

Re: Newb problem sending mail from form

Posted: Tue May 13, 2008 10:36 pm
by hooly69
...which is ??

Re: Newb problem sending mail from form

Posted: Tue May 13, 2008 10:58 pm
by Chris Corbyn
Sorry, I'm not trying to be cruel but I'm basically not here to do your reading for you ;) I'll give you a hint; where did the $swift variable magically appear from?

Re: Newb problem sending mail from form

Posted: Wed May 14, 2008 6:19 am
by hooly69
man you're making this hard for me, i'm not a programmer and never used php before, just trying to use a form as a one off, thought this was a help forum ?

Re: Newb problem sending mail from form

Posted: Wed May 14, 2008 6:30 am
by Chris Corbyn
hooly69 wrote:man you're making this hard for me, i'm not a programmer and never used php before, just trying to use a form as a one off, thought this was a help forum ?
It is. That's why I'm pointing you to the documentation and telling you exactly which bits of it to read. If you stick around you'll see that we're not really in the habit of writing people's code for them, instead we prefer that people try to understand the code and learn a little by coming here. it's very rewarding to actually learn something new! On all those "tutorial" pages there's a line with

Code: Select all

$swift = /* something here */
You're missing that line; read the wiki to work out what goes there... or even just scan over some other posts on this forum. I'm actually going to more effort by trying to get you to read the manual than if I just posted the code for you ;)

Re: Newb problem sending mail from form

Posted: Wed May 14, 2008 2:47 pm
by hooly69
i post a note on the forum for help and am told rtfm, forget it, i'll use something else.

Re: Newb problem sending mail from form

Posted: Wed May 14, 2008 6:12 pm
by califdon
hooly69 wrote:i post a note on the forum for help and am told rtfm, forget it, i'll use something else.
I think that's a good idea for you.