FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Using mail() func on Frihost





Naif
I am kind of new to PHP programming. The only thing I am comfortable is with its syntax. I have written a feedback script which accepts a Name, Email Address, Website and a Message from a form. The variables names are msgName, msgEA, msgWebsite, mMessage. The php code is as follows

Code:

<?php
if( mail("prince_of_nights@hotmail.com", "SRK Fansite", $_POST['msgEA'] + $_POST['msgWebsite'] + $_POST['mMessage']) == true) {
   echo "Your feedback has been sent! Thank you";
}
else {
   echo "There seems to be a problem with the mail server. Your feedback was not sent at this time. Please try again later. We apologise for the inconvenience";
}

?>


The form gets submitted and the mail function returns true and therefore the message "Your feedback has..." is being displayed, yet.... yup, here is the yet... yet I am getting no mail. My email address is correct, I have checked the syntax of mail(), that too is correct. Do I have to initialise particular variables to use FRIhost's SMTP daemon, if so, what are the variables and how would I go about initialising them?

By the way, I have already tried using the forum's search function to see if whether this question was posted earlier but it was of no help so thats why I decided to start a new thread.
thnn
Try this it should work. I would use periods not addition signs to join strings.

Code:
<?php
if( mail("prince_of_nights@hotmail.com", "SRK Fansite",

$_POST['msgEA'].$_POST['msgWebsite'].$_POST['mMessage']) == true) {
   echo "Your feedback has been sent! Thank you";
}
else {
   echo "There seems to be a problem with the mail server. Your feedback was not sent at

this time. Please try again later. We apologise for the inconvenience";
}

?>


It worked on my PHP installation with mercury, but it could also be the Frihost mail server software.
Naif
I will give that a try and will get back to you. It slipped from my mind we are supposed to use a dot instead of an addition operator for concatenation of strings.
Naif
Modified the code but still no luck. I thought maybe it would take some time for the mail to reach my inbox but it has been 5 hours since I tried last. I have checked the junk folder of my Inbox too.
izcool
This is a quick thing that I can suggest for you to do :

Code:
<?php
mail("your@address.com","Title","Message","From: Whoever<whoever@address.com>") or exit("Your mail was not sent.  Sorry.");
?>


- Mike.
mostarac
This should work.

Code:

<?
$_POST['msgEA'] = $ea
$_POST['msgWebsite'] = $website
$_POST['mMessage'] = $message

mail("email@domain.tld", "Subject", "$ea\n$website\n$message");
echo "Mail sent!";


EnJoy! Twisted Evil
thnn
I tried the edited version on Frihost and it worked fine
Naif
Nope. Still it isnt working. Is it only me who is having problems with this function? Confused

By the way, I forgot to add one thing. Maybe I should have added this earlier but then like they say, better late than never. I havent configured nor have I changed any mail settings from DirectAdmin. Could that be a reason? Or maybe this is because my account is located on the new server? I am blank right now.
thnn
Interesting I am on the direct admin and it worked fine.

Did you check your junkmail on hotmail???
Naif
thnn wrote:
I tried the edited version on Frihost and it worked fine


I know, I read your post. I copied the code AS IS but it was of no avail.

thnn wrote:

Interesting I am on the direct admin and it worked fine.

Did you check your junkmail on hotmail???


Yes I have... I will try using a yahoo address... who knows, maybe it will work! (fingers crossed)
thnn
you could try making a email address on your account to send it to on DirectAdmin and access it through your webmail
Naif
Hey thnn... Finally I have figured out what the problem is though my findings are quite odd! The problem is someway or the other related to Hotmail. I received the feedback on my yahoo account.

I tried what you suggested me and it worked fine. So I thought I would direct the feedback messages to my frihost email a/c and from direct admin, I will configure the forwarder to forward it to my hotmail a/c, but that too doesnt work.

Maybe frihost's mail handler daemon is having problems trying to route mails to hotmails server?
thnn
it could also have something to do with Hotmail itself.
Naif
True... thats possible too. I will try mailing something from hotmail to see if the mail gets delivered or bounces back.
izcool
Try putting the mail() function that I recommended to you on a test page to see if it's a problem with your specific account. Although I bet it will work and isn't a problem with your account, I'm assuming that some other part of your code is making it function improperly. I just remembered that I had some issues with that too when I was scripting a few pages like that. I think you need to have your header() tags specifically set so that they will be compatable with your mail() tags later on in your codes. Hope that's the problem, that would really help out if it is by pinpointing it to that instead of a million other possibilities.

- Mike.
Naif
@mike: I think you are right. After googling for "php mail() hotmail" I have found out I am not the only one having problems trying to use PHP to send mails to hotmail a/c's. On one page I read we have to use proper headers or hotmail wont accept the mails. The issues you had, were they with hotmail a/c's too?

@thnn: You said your script worked fine on Frihost. Did you use a hotmail a/c or a different one?

I will get back to you guys if I am successful in solving this problem.
Related topics
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.