Jump to content

Need Help with mail() function


chobo2

Recommended Posts

Hi

 

I need your guys help. First off let me just say I am a php noob(less then a week using php) so please assume I know nothing because I don't  ;D

 

I have made a mailer so when a user creates an account it emails them their username and password.

 

Here is my code:

 

* This stores the incoming email address from the form and puts it into another variable */
$to = $email;
/* this is where the subject header of the email will go */
$subject = "Welcome to ----!";
/* this is where the body of the email will go. In the message it uses the users name by taking it from the form. It also does this same thing for username and password */
$body =<<< emailbody

PLEASE DO NOT RESPOND TO THIS EMAIL

Dear $fName $lName,

This email confirms that you have sucessfuly created an acount at -----

Here is your account information:

username: $user
password: $pass

Please keep this incase you forget your username or password.

Thank you,
The ---- staff
emailbody;

/* this is where your email address goes */
$headers = "From: [email protected]\n";

/* this tells the user if it they will get a email or if it failed to send the email */
if(mail($to,$subject,$body,$headers)) 
{
echo "An e-mail was sent to $to with the subject: $subject";
echo '<br />';
} 
else 
{
echo "There was a problem sending the mail. Check your code and make sure that the e-mail address $to is valid \n";
echo '<br />';

 

So I finally got it to work on my computer since I did not know I had to go into the php.ini file and setup a smtp address from my isp.

 

But now I need to upload it to a php web hosting site(a free one) but the one I use does not allow this mail() function. I get a warning bitch about it:

Warning: mail() [function.mail]: Safety Restriction in effect. The mail() command is not allowed, contact the admin. in /www/110mb.com/b/c/i/t/2/_/_/_/bcit2/htdocs/login2/Login/autoSendEmail.php on line 46
There was a problem sending the mail. Check your code and make sure that the e-mail address [email protected] is valid
User account created
You will be redirected in 3 seconds...

 

It also looks like they won't enable it. So is their away I can get around this by using my own smtp server or something like that.

 

or

 

does anyone know a freeweb hosting site that I can use that supports this and also supports php5 and mysql 5.0(eventhough I might be able to get away with a older version since all I have is a simple table).

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/46036-need-help-with-mail-function/
Share on other sites

Hi,

You should be able to use php 4 with a simple script like that.

Try this host.. I use them and they seem quite good, although I have a paid account. I just checked the stats of the trial account and it looks like you can use mail() function on it. I know you can for paid and I see no restriction on the list of options for the free one.

https://www.streamlinenet.co.uk

 

Hope this helps

Hi,

You should be able to use php 4 with a simple script like that.

Try this host.. I use them and they seem quite good, although I have a paid account. I just checked the stats of the trial account and it looks like you can use mail() function on it. I know you can for paid and I see no restriction on the list of options for the free one.

https://www.streamlinenet.co.uk

 

Hope this helps

 

Hmm I don't have a credit card so I can't sign up.

oh sorry. I hadn't realised you had to put credit card details in for trial user.. I also just noticed that it's a 3 month trial.. not a free account type thing.

Sorry.

 

Try googling for a host.

 

Been googling for like the last hour and found nothing that has it enabled

ah. that's why I decided to pay for hosting. I was fed up with so little options and all the banner ads everywhere..

 

Ya well I just need something that I can use till the end of the month since this is for a project and most of my school computers don't have it setup(or I don't know how access it) and my teacher who is marking this does not really want to set it up(this is for a competion but my teacher is allowing us to do this instead of one of are asp assignments so thats why nothing is really setup for php or if it is I don't know how to access it.)

yeah okay. It's a uk hosted site though, so if I register the sub-domain tonight it probably wont be up until monday GMT.

 

Do you have any preference for the sub-domain name?

 

you can call it after my school BCIT.

 

Ok cool that should be fine I still have to wait to get the design part of the site(if my group members do it) then put my login & registration form into it. So Monday should be fine.

 

Thanks again.

the operating system you use has nothing to do with the server type.

Windows type of hosting can take up a lot of extra space, but is more user friendly, whereas linux is the bare bones, just what you need.

I guess as you're only going to be using ftp to upload stuff and phpmyadmin for databases I'd use Linux, because otherwise I'll end up with quite a bit of space taken up by windows stuff that's not needed.

 

Host type has nothing to do with operating system. I use windows xp on my computer but my hosting is Linux.. it's also generally cheaper on most hosts :P

the operating system you use has nothing to do with the server type.

Windows type of hosting can take up a lot of extra space, but is more user friendly, whereas linux is the bare bones, just what you need.

I guess as you're only going to be using ftp to upload stuff and phpmyadmin for databases I'd use Linux, because otherwise I'll end up with quite a bit of space taken up by windows stuff that's not needed.

 

Host type has nothing to do with operating system. I use windows xp on my computer but my hosting is Linux.. it's also generally cheaper on most hosts :P

 

Ok whatever you think is best since you obviously know more then me. If I have any questions I will just ask you. Just set it up so I can't screw any of your stuff up(since thats the last thing I would want to do to you.)

haha. you shouldn't be able to touch any of my stuff as they're on seperate servers.

I'll pm you the login details once they're set up.

 

ok thanks I will send you my email(through pm) instead of you sending me pm once setup. Since I may forget to check to see if I gotten any messages.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.