Page 1 of 1
HELP!!!
Posted: Tue Jan 13, 2009 10:23 pm
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.

Re: HELP!!!
Posted: Tue Jan 13, 2009 10:40 pm
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
Re: HELP!!!
Posted: Tue Jan 13, 2009 11:19 pm
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?
Re: HELP!!!
Posted: Wed Jan 14, 2009 12:31 am
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

Re: HELP!!!
Posted: Wed Jan 14, 2009 5:52 pm
by TheShirey
Do i have my " and my ' in the right place or the wrong?
Re: HELP!!!
Posted: Wed Jan 14, 2009 9:39 pm
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?
Re: HELP!!!
Posted: Thu Jan 15, 2009 10:53 pm
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.