Page 1 of 1

how to send email in php(solved)

Posted: Sat Oct 29, 2011 3:53 am
by dust1031
ok what i'm basically trying to do is make it to where when a player registers there account it sends them a email telling them to activate your account, i pretty much got everything working except, when a player registers and it tries to send the email it comes up.

( ! ) Warning: mail() [function.mail]: Failed to connect to mailserver at "hotmail.com" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\wamp\www\tutorial\reguser.php on line 70

here is my whole mail code

Code: Select all

$lastid = mysql_insert_id();
$to = $email;
$subject = "Activate your account!";
$headers = "From: Admin@EpicWorlds.com";
$server = "hotmail.com";
ini_set("SMTP",$server);
$body = "Hello $player,You have just made an account with Epic Worlds, To get started using your account, You need to activate your account with the link below. Once you do that you can log in
:http://localhost/tutorial/tutorials/register-login/activation.php?id=$lastid&code=$random";
mail($to, $subject, $body,$headers);
print "Thank you for registering! Check you email to activate your account!";
please help me, this is my last step then i will have the code fixed and ready to go. then ill post it in the codes section for everybody to use.

Re: (HELP)how to send email in php

Posted: Sat Oct 29, 2011 11:41 am
by Chris
How this works is the mail() function creates a connection to a remote mail server to send an email from. This script is editing your php.ini file to connect to a mail server, in this case an SMTP server, hotmail.com. Every time you try to send an email using the mail() function PHP is going to try to connect to the SMTP server on the domain hotmail.com, send it the data of the email to be sent, then the hotmail.com mail server will send the email for you. Here's a really good tutorial on how to connect to a remote mail server using username and password authentication:

http://email.about.com/od/emailprogramm ... cation.htm

Re: (HELP)how to send email in php

Posted: Sat Oct 29, 2011 6:04 pm
by dust1031
do you have a video i can watch. i can understand it more by watching a video, then reading it

Re: (HELP)how to send email in php

Posted: Sat Oct 29, 2011 7:55 pm
by Chris
Haven't watched it but try this: http://www.youtube.com/watch?v=ppsO37xOUS4

Re: (HELP)how to send email in php

Posted: Sat Oct 29, 2011 11:36 pm
by dust1031
alright, that fixed the error. and no errors came up once i installed that program that he talked about. but when i went to check my email, the activation message wasn't there.

Re: (HELP)how to send email in php

Posted: Sat Oct 29, 2011 11:42 pm
by Jackolantern
I believe the tutorial at buildingbrowsergames.com includes email verification for registration. As I have said many times before, though, I suggest against email verification. Pretty much every commercial PBBG stopped using it, and that should really be reason enough (you don't want to be the last guy on the block with an extra hurdle to begin playing). It also does not add really any security since pretty much everyone uses free email services now, and anyone can get 10 new addresses any time they want; they don't identify anyone.

Re: (HELP)how to send email in php

Posted: Sun Oct 30, 2011 12:10 am
by dust1031
i also need the email to work, so i can finish the forgot password page im making, so the server can send the email with the password

Re: (HELP)how to send email in php

Posted: Sun Oct 30, 2011 1:10 am
by Callan S.
I agree with Jack but am interested for the same reason as Dust - at some point I want to build in a forgotten password capacity.

Re: (HELP)how to send email in php

Posted: Sun Oct 30, 2011 1:15 am
by Jackolantern
What mail server are you using?

And as far as emails go, I have always thought a better method would be to allow the players to start playing as soon as they register, but then offer them something they can't pass up to give you their email address, such as a free mount or a free level-up (just make it something that sounds very enticing, but something you can give everyone). Kind of a "helping them help themselves" sort of thing lol. That way you still have the email for forgot password, and you aren't adding an additional barrier to entry.

This is similar to how World of Warcraft gives you a free pet item for adding a security token to their account.

Re: (HELP)how to send email in php

Posted: Sun Oct 30, 2011 1:34 am
by dust1031
im using postcast as my mail server. its from the video that chris gave me