HELP!!!

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
TheShirey
Forum Newbie
Posts: 4
Joined: Tue Jan 13, 2009 10:20 pm

HELP!!!

Post by TheShirey »

I'm new to using PHP to send emails from a website. I usually use ASP.NET for my design but I had a client that wanted a basic site and I wanted to use PHP to send an email. I came across this site and really want to use the product but I don't know what I'm doing or what to do to get this working for me. I have a PHP editor so I'm good there. I'm just not sure what files to edit to get this working.

Thanks. :banghead:
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: HELP!!!

Post by s.dot »

Hi, please use a more descriptive title. Titles like "help" are vague and often times gather no interest for response. You can help us help you more by using a more descriptive title. :)

As far as using Swift goes, have you downloaded it and installed it?

You can download it from here: http://sourceforge.net/project/showfile ... _id=193923

Instructions for installing are here: http://www.swiftmailer.org/wikidocs/

You don't need to edit any files to get it working, however you do need to create a new file to use the Swift software. Sample files are included in the documentation, such as how to send a basic email: http://www.swiftmailer.org/wikidocs/v3/tutorials/basic
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
TheShirey
Forum Newbie
Posts: 4
Joined: Tue Jan 13, 2009 10:20 pm

Re: HELP!!!

Post by TheShirey »

Okay. Sorry about that.

Say I was to use the following code:

Code: Select all

 
<?php
 
//Load in the files we'll need
require_once "lib/Swift.php";
require_once "lib/Swift/Connection/SMTP.php";
 
//Start Swift
$swift =& new Swift(new Swift_Connection_SMTP("smtp.your-host.tld"));
 
//Create the message
$message =& new Swift_Message("My subject", "My body");
 
//Now check if Swift actually sends it
if ($swift->send($message, "foo@bar.tld", "me@mydomain.com")) echo "Sent";
else echo "Failed";
?>
 
I'm using GMAIL account to send to.

What is the "foo@bar.tld" and "me@mydomain.com" ????

Say I have some data that I'm sending to the mail.php from a form and it looks like this....
$body = " Name: " . $_POST['SenderName'] . " /n Email: " . $_POST['SenderEmail'] . " /n Message: " . $_POST['SenderMessage'] . "";
What am I doing wrong?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: HELP!!!

Post by Chris Corbyn »

Did you even read the documentation? Those fields are for the sender and the recipient(s).

I'm not sure what you mean by what are you doing wrong. What's going wrong?

PS: \n, not /n ;)
TheShirey
Forum Newbie
Posts: 4
Joined: Tue Jan 13, 2009 10:20 pm

Re: HELP!!!

Post by TheShirey »

Do i have my " and my ' in the right place or the wrong?
TheShirey
Forum Newbie
Posts: 4
Joined: Tue Jan 13, 2009 10:20 pm

Re: HELP!!!

Post by TheShirey »

I uploaded the lib folder to my site. After doing this and I attempt to submit a message I get the following error:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in D:\Hosting\3384878\html\ShireTest\sendemail.php on line 41.

In the sendmail.php file line 41 looks like this.

Code: Select all

 
 $MySubject = " . $_POST['SenderSubject'] . ";
 
What could be wrong?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: HELP!!!

Post by Chris Corbyn »

This is basic PHP so perhaps you need to learn a little PHP before continuing. Drop the " . and the . ", they are what is breaking that line of code.

If you put

Code: Select all

 and [ /php] tags around your code in this forum you'll see with syntax highlighting why that is broken:

[syntax=php]$MySubject = " . $_POST['SenderSubject'] . ";[/syntax]

Strings are red... notice what the above looks like with syntax highlighting?

Now look at this correct version:

[syntax=php]$MySubject = $_POST['SenderSubject'];[/syntax]

It sounds as though you need to download a proper PHP editor too (are you using windows notepad or some other plain-text editor?).  PHP editors will do such syntax highlighting for you so that you can easily see your syntax errors such as the above.
Post Reply