how to send email in php(solved)

Location of the Videos
Post Reply
dust1031
Posts: 92
Joined: Fri Jul 22, 2011 3:38 am

how to send email in php(solved)

Post 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.
Last edited by dust1031 on Tue Nov 01, 2011 2:46 am, edited 3 times in total.
User avatar
Chris
Posts: 1580
Joined: Wed Sep 30, 2009 7:22 pm

Re: (HELP)how to send email in php

Post 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
Last edited by Chris on Sat Oct 29, 2011 7:53 pm, edited 2 times in total.
Fighting for peace is declaring war on war. If you want peace be peaceful.
dust1031
Posts: 92
Joined: Fri Jul 22, 2011 3:38 am

Re: (HELP)how to send email in php

Post by dust1031 »

do you have a video i can watch. i can understand it more by watching a video, then reading it
User avatar
Chris
Posts: 1580
Joined: Wed Sep 30, 2009 7:22 pm

Re: (HELP)how to send email in php

Post by Chris »

Haven't watched it but try this: http://www.youtube.com/watch?v=ppsO37xOUS4
Fighting for peace is declaring war on war. If you want peace be peaceful.
dust1031
Posts: 92
Joined: Fri Jul 22, 2011 3:38 am

Re: (HELP)how to send email in php

Post 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.
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: (HELP)how to send email in php

Post 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.
The indelible lord of tl;dr
dust1031
Posts: 92
Joined: Fri Jul 22, 2011 3:38 am

Re: (HELP)how to send email in php

Post 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
User avatar
Callan S.
Posts: 2042
Joined: Sun Jan 24, 2010 5:43 am

Re: (HELP)how to send email in php

Post 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.
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: (HELP)how to send email in php

Post 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.
The indelible lord of tl;dr
dust1031
Posts: 92
Joined: Fri Jul 22, 2011 3:38 am

Re: (HELP)how to send email in php

Post by dust1031 »

im using postcast as my mail server. its from the video that chris gave me
Post Reply

Return to “Older Browser MMO Videos”