Basic PHP email question

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

Post Reply
ave
Forum Newbie
Posts: 6
Joined: Fri Feb 11, 2005 6:09 am

Basic PHP email question

Post by ave »

I have a flash web site on easyspace servers, it has an e-mail form which works ok elsewhere but wont work on their servers as they say it needs different code to work.
The base code is as follows

Code: Select all

<?php
mail("me@myemail.com", $subject, $message, "From: PHPMailer\nReply-To: $from\nX-Mailer: PHP/" . phpversion());
?>
However on easyspace it says the following....
Using PHP with easymail
As you can see from the installation we have PHP setup to use our easymail system on the webserver.
You still use the mail() function but you need to send a "From" header including a valid email address.
EG.
mail ( "someone@somedomain.com" , "subject" , "message" , "From: server@easyspace.com" );
so i changed my code to read as above and it still didnt work ??

Please any help on this will be greatly appreciated as ive asked easyspace helpdesk 5 days ago !! and still no reply
(as you may have guessed im not exactly very good with PHP so forgive the stupidness of this question)
AGISB
Forum Contributor
Posts: 422
Joined: Fri Jul 09, 2004 1:23 am

Post by AGISB »

You might want to consider using an external mail function like phpmailer.
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post by Maugrim_The_Reaper »

phpmailer, it's a simple mailing class that let's you create a setup script for all the values and then send the email.

http://phpmailer.sourceforge.net/

Might also try a less generic from email - in case it's been screened.
ave
Forum Newbie
Posts: 6
Joined: Fri Feb 11, 2005 6:09 am

Post by ave »

so is there no way to get my original simple script working ?
I mean it works fine on my other site...

I am not very good at PHP and also i have to integrate it into a FLASH form... hmm this is a problem, thanks for the help so far though ill certainly look at the link you posted.
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

Code: Select all

<?php
mail("me@myemail.com", $subject, $message, "From: PHPMailer@mysite.com\nReply-To: $from\nX-Mailer: PHP/" . phpversion());
?>
Did you read the error..?
It told you what to do.

Also, where is $from coming from? If it's YOUR email, thats what you should be using.. (not PHPMailer).
ave
Forum Newbie
Posts: 6
Joined: Fri Feb 11, 2005 6:09 am

Post by ave »

ok not to sound ungrateful but one thing ?
What error ??

And ok the problem is i am translating dynamic text fields in FLASH to an e-mail format.
Im also not sure i understand what you meant here
Also, where is $from coming from? If it's YOUR email, thats what you should be using.. (not PHPMailer).
To clarify i have now tried altering the code as you suggested, and as easyspace suggested and ive even removed this part

Code: Select all

\nReply-To: $from\nX-Mailer: PHP/
so it functions normally and it still doesnt work, things is it works fine as it had it set up originally but on easyspace servers it just wont have it
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

talk to their support then.
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

ave wrote:ok not to sound ungrateful but one thing ?
What error ??
Using PHP with easymail
As you can see from the installation we have PHP setup to use our easymail system on the webserver.
You still use the mail() function but you need to send a "From" header including a valid email address.
EG.
mail ( "someone@somedomain.com" , "subject" , "message" , "From: server@easyspace.com" );
It's tell you, that you need your email in the correct format, user@domain.com, and you put "PHPMailer" which isn't in that form.
And ok the problem is i am translating dynamic text fields in FLASH to an e-mail format.
Im also not sure i understand what you meant here
Also, where is $from coming from? If it's YOUR email, thats what you should be using.. (not PHPMailer).
To clarify i have now tried altering the code as you suggested, and as easyspace suggested and ive even removed this part

Code: Select all

\nReply-To: $from\nX-Mailer: PHP/
so it functions normally and it still doesnt work, things is it works fine as it had it set up originally but on easyspace servers it just wont have it
What does your code look like now?

And what I meant was, how is the $from variable set? or where?
ave
Forum Newbie
Posts: 6
Joined: Fri Feb 11, 2005 6:09 am

Post by ave »

feyd wrote:talk to their support then.
i have and its taken 6 days and NO response as i said originally was hoping some one might have had the same problem already.

In reply to 'LiLpunkSkateR'

The $from is defined by a text field in the flash movie and basically it add a 'REPLY TO' field to the e-mail telling you who sent it and allowing you to reply.
So to clarify as this has all got rather confusing (for me anyway lol)
My code now looks like this....

Code: Select all

<?php 
mail("me@myemail.com", $subject, $message, "From: User@domain.com\nReply-To: $from\nX-Mailer: PHP/" . phpversion()); 
?>
And it still doesnt work...?
wierd very wierd, or maybe im just being thick, which believe me wouldnt be the first time :)
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

Hmm.. maybe try your actual email? Could be they have a strict anti spam policy and anything with domain.com is caught as well?
ave
Forum Newbie
Posts: 6
Joined: Fri Feb 11, 2005 6:09 am

Post by ave »

Have tried that already, its most peculiar...
(Where ever i wrote generic comments like 'me@mydomain.com' i actually put the real adress's in)
But no joy still...
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

what about their strict format they show in their example? If that works, then slowly poke out of that checking each one to see if it's blocked. After you run through all the options you wanted to use, you should have a map of all that are valid/allowed and that aren't.. may also want to try \r\n instead of \n
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

feyd wrote:what about their strict format they show in their example? If that works, then slowly poke out of that checking each one to see if it's blocked. After you run through all the options you wanted to use, you should have a map of all that are valid/allowed and that aren't.. may also want to try \<span style='color:blue' title='ignorance is bliss'>are</span>\n instead of \n
haha, feyds filtering comes to bite him in the ass ;)
ave
Forum Newbie
Posts: 6
Joined: Fri Feb 11, 2005 6:09 am

Post by ave »

thanks for the continued help everyone, still havent sorted it but ill try 'feyd's' suggestion tomorrow, i think thats the only option i have left aside from trying a totally different approach.
Post Reply