Newb problem sending mail from form

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

Post Reply
hooly69
Forum Newbie
Posts: 4
Joined: Tue May 13, 2008 7:16 pm

Newb problem sending mail from form

Post 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.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Newb problem sending mail from form

Post 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 ;)
hooly69
Forum Newbie
Posts: 4
Joined: Tue May 13, 2008 7:16 pm

Re: Newb problem sending mail from form

Post by hooly69 »

...which is ??
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Newb problem sending mail from form

Post 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?
hooly69
Forum Newbie
Posts: 4
Joined: Tue May 13, 2008 7:16 pm

Re: Newb problem sending mail from form

Post 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 ?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Newb problem sending mail from form

Post 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 ;)
hooly69
Forum Newbie
Posts: 4
Joined: Tue May 13, 2008 7:16 pm

Re: Newb problem sending mail from form

Post by hooly69 »

i post a note on the forum for help and am told rtfm, forget it, i'll use something else.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Newb problem sending mail from form

Post 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.
Post Reply