Email Frustrations

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

dgarrett
Forum Newbie
Posts: 20
Joined: Sun Sep 15, 2002 8:54 pm
Location: CA, UT

Email Frustrations

Post by dgarrett »

I am atempting to get this code to work, it takes variables from flash, and emails them to me from the flash form. The problem after my six hour trial and error debugging, I believe has nothing to do with flash, but is this php. The flash simply sends the varaibles to this php code that is not mailing.

My theroy is it must be somthing to do with my quotes or some syntax trouble. If I use a very basic mail() without variables it works, but what good is that really. Thanks in advance for any tips here is the loosing code:

Code: Select all

<?php
$ToEmail = "dustingarrett@yahoo.com";
$ToName = "Dustin";
$ToSubject = "New Remedy Motel Mailing List Entry";

$EmailBody = "'Sent By:' $FirstName 'Senders Email:' $Email 'Address:' $Address";

//$EmailFooter="This message was sent by: $FirstName  If you feel that you
//recieved this e-mail by accident please contact us at www.whitedotgroup.com";

//$Message = $EmailBody
//.$EmailFooter;

mail($ToName." <".$ToEmail.">", $ToSubject, $EmailBody, "From: ".$FirstName." <".$Email.">");
Print "_Root.Mail.EmailStatus=Complete - Your mail has been sent";
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post by Takuma »

Code: Select all

&lt;?php
$ToEmail = "dustingarrett@yahoo.com"; 
$ToName = "Dustin"; 
$ToSubject = "New Remedy Motel Mailing List Entry"; 

$EmailBody = "Sent By: $FirstName\n Senders Email: $Email\n Address: $Address"; 

mail($ToName." &lt;".$ToEmail."&gt;", $ToSubject, $EmailBody, "From: ".$FirstName." &lt;".$Email."&gt;"); 
Print "_Root.Mail.EmailStatus=Complete - Your mail has been sent";
?&gt;
Try this and if you do this

Code: Select all

&lt;?php
mail("YOURADDRESS","SUBJECT","MESSAGE");
?&gt;
Does it work? If it doesn't there's something wrong with our PHP try editing php.ini.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Since the data is coming from a form, have you read this:
http://www.devnetwork.net/forums/viewtopic.php?t=511

Mac
dgarrett
Forum Newbie
Posts: 20
Joined: Sun Sep 15, 2002 8:54 pm
Location: CA, UT

Post by dgarrett »

OK Thanks for the advice, I skimmed throught the forms primer, it looks as this won't apply to me because I am using 4.1. It seems so simple. I used the same code, which it close to what I came up with after re-reading the first three chapters of my php book. But still it does not work... If anyone it stil interested in this annomoly here is continued saga:

The code is as follows:

Code: Select all

&lt;?php
$ToEmail = "dustingarrett@yahoo.com"; 
$ToName = "Dustin"; 
$ToSubject = "New Remedy Motel Mailing List Entry"; 

$EmailBody = "Sent By: $FirstName\n Senders Email: $Email\n Address: $Address"; 

mail($ToName." &lt;".$ToEmail."&gt;", $ToSubject, $EmailBody, "From: ".$FirstName." &lt;".$Email."&gt;"); 
Print "_Root.Mail.EmailStatus=Complete - Your mail has been sent";
?&gt;
Here is what I have used to pass the variables to take flash out of the loop

Code: Select all

http://remedymotel.com/pages/dust_mail.php?FirstName=rudy&amp;Address=brier&amp;Email=tooty
And the result is
Warning: Server Error in U:\users\r\remedy\pages\dust_mail.php on line 8
_Root.Mail.EmailStatus=Complete - Your mail has been sent
Line 8 Being the mail page the problem, Now if I remove the $EmailBody variable and change it to a string ie "test".

the result is this, as it should work
_Root.Mail.EmailStatus=Complete - Your mail has been sent
But sadly no email is recieved... I Am at a loss here :cry:

FYI this does work

Code: Select all

&lt;?php
mail("to","subject","body");
?&gt;
Thanks Again Dustin
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post by Takuma »

Code: Select all

&lt;?php
$ToEmail = "dustingarrett@yahoo.com";  
$ToName = "Dustin";  
$ToSubject = "New Remedy Motel Mailing List Entry";  

$EmailBody = "Sent By: {$_GET&#1111;'FirstName']}\n Senders Email: {$_GET&#1111;'Email']}\n Address: $_GET&#1111;'Address']}";  

$ToEmail = $ToName." &lt;".$ToEmail."&gt;";
$from = "From: ".$_GET&#1111;'FirstName']."&lt;".$Email."&gt;";

mail($ToEmail, $ToSubject, $EmailBody,$from);  
Print "_Root.Mail.EmailStatus=Complete - Your mail has been sent";  
?&gt;
How about this?
dgarrett
Forum Newbie
Posts: 20
Joined: Sun Sep 15, 2002 8:54 pm
Location: CA, UT

Post by dgarrett »

Now I get this:
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in U:\users\r\remedy\pages\dust_mail.php on line 6
I don't know this also seems as if it should work, thanks for the help, I don't blaim you if you want to give up, this seems so rudamentary.
dusty
Forum Contributor
Posts: 122
Joined: Sun Apr 28, 2002 9:52 pm
Location: Portsmouth, VA

Post by dusty »

{$_GET['Address']} in the email body. you forgot the opening {
dgarrett
Forum Newbie
Posts: 20
Joined: Sun Sep 15, 2002 8:54 pm
Location: CA, UT

Post by dgarrett »

Now this:
Warning: Server Error in U:\users\r\remedy\pages\dust_mail.php on line 11
_Root.Mail.EmailStatus=Complete - Your mail has been sent
I sort of keeping a log here to show my hosting company to see if they have any comments on the matter. Again thank you
dusty
Forum Contributor
Posts: 122
Joined: Sun Apr 28, 2002 9:52 pm
Location: Portsmouth, VA

Post by dusty »

i'm guessing you're on a windows server and smtp isn't set in php.ini
dgarrett
Forum Newbie
Posts: 20
Joined: Sun Sep 15, 2002 8:54 pm
Location: CA, UT

Post by dgarrett »

It is on a windows server, but I believe the mail is configured beacause this function works as long as there are no variable involved.

Code: Select all

&lt;?php
mail("YOURADDRESS","SUBJECT","MESSAGE"); 
?&gt;
This is becoming tiresome, if I can't get this to work I'm starting to think I'm doomed... SOmthing must be fishey here, as the code others have posted looks perfect to me? 8O
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post by Takuma »

If you change YOURADDRESS to your real-email address does it sends an e-mail to you?
dgarrett
Forum Newbie
Posts: 20
Joined: Sun Sep 15, 2002 8:54 pm
Location: CA, UT

Post by dgarrett »

It does not, it give me a serve error:
Warning: Server Error in U:\users\r\remedy\pages\dust_mail.php on line 11
_Root.Mail.EmailStatus=Complete - Your mail has been sent
But if I take out all variable and just use text it does work? Wierd. Thenks for all the effort
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

i'd try doing some error checking like;

Code: Select all

echo $EmailBody;
right before the mail() function to see what you're emailing.
dgarrett
Forum Newbie
Posts: 20
Joined: Sun Sep 15, 2002 8:54 pm
Location: CA, UT

Post by dgarrett »

good tip i'll giv it a go.
dgarrett
Forum Newbie
Posts: 20
Joined: Sun Sep 15, 2002 8:54 pm
Location: CA, UT

Post by dgarrett »

So it seems as if the variables are set as seen in a not so pretty mannor here:
ToEmail: Dustin ToName: Dustin ToSubject: New Remedy Motel Mailing List Entry EmailBody: Sent By: rudy Senders Email: tooty Address: brier From: From: rudy
Warning: Server Error in U:\users\r\remedy\pages\dust_mail.php on line 16
_Root.Mail.EmailStatus=Complete - Your mail has been sent
you can check out the phpinfo at http://www.remedymotel.com/pages/phpinfo.php

if that will help anyone with ideas, but it does work as long as I enter a actual string "sample", for the toemail, and body, it will actually send with the toemail variable when is is simplified to just a plain email address....
Post Reply