I want to do the email a link to reset the password for the extra feature although i'm not sure where to start.

Looked around and This page has instructions for sending email through a localhost. First step is finding where php.ini exist. Anyone mind telling me where it is? Or whether i'm going in the right direction?

1 Answer 1


You will have to figure out on your own how to get the user's address but if you want the code for how to send an email, you can use the phpmailer as described in a walkthrough video and here, and the relative code is as follows:

the following code uses a gmail account to send the emails


    $mail = new PHPMailer();
    $mail->SMTPAuth = true;
    $mail->SMTPSecure = "tls";
    $mail->Host = "smtp.gmail.com"; // change to your email host
    $mail->Port = 587; // change to your email port
    $mail->Username = "[email protected]"; // change to your username
    $mail->Password = "myOneTimePasswordBecauseOfTwoStepAuth"; // change to your email password
    $mail->setFrom("[email protected]"); // change to your email password
    $mail->AddAddress("[email protected]"); // change to user's email address
    $mail->Subject = "trial"; // change to email's subject
    $mail->Body = "<h1>hello, world!</h1>"; // change to email's body, add the needed link here

    if ($mail->Send() == false)
        echo "It worked!\n";

If you want to send emails from the appliance itself I think you would have to install an email server, and that is probably an overkill for this course.


Common SMTP servers:


  • Gmail SMTP server name: smtp.gmail.com
  • Gmail SMTP user name: your Google account
  • Gmail SMTP password: your Google password
  • Gmail SMTP port: 587


  • Hotmail SMTP server name: smtp.live.com
  • Hotmail SMTP user name: your Hotmail account
  • Hotmail SMTP password: your Hotmail password
  • Hotmail SMTP port: 25 or 465


  • Yahoo! SMTP server address: smtp.mail.yahoo.com
  • Yahoo! SMTP user name: your Yahoo! Mail account
  • Yahoo! SMTP password: your Yahoo! Mail password
  • Yahoo! SMTP port: 465

Extra Info

Regarding the different ports (587 vs 465 vs 25) see this really helpful site

  • Please, help me to understand the following: $mail->Host = "smtp.gmail.com"; // change to your email host and $mail->Port = 587; // change to your email port - if I am working in cs50.io, which email host and port should I use?
    – Vitale
    Commented Aug 4, 2016 at 8:25
  • cs50.io doesn't include a mail server, so you can't send emails directly from it. So what I do above, is I use Gmail's servers to send the email. If you want to learn more about how to install a mail server on your machine check this . Although I should re-mention that it's an overkill for this course. Just use your standard mail provider's servers.
    – ChrisG
    Commented Aug 4, 2016 at 8:31
  • thank you very much for your answer. One more question, if I may: checking google's page, I have found out that I can use IP address for authentication instead of providing my email and password if I use Google Apps SMTP relay support.google.com/a/answer/176600?hl=en but I don't see how to add an IP. Shall it be $mail->IP = xxx.xx.xxx ? Thank you very much!
    – Vitale
    Commented Aug 4, 2016 at 9:23
  • I'm sorry but I don't have any clue about that. You could keep googling and I'm sure you will find the answer.
    – ChrisG
    Commented Aug 4, 2016 at 9:26
  • 1
    I see ))) Thank you.
    – Vitale
    Commented Aug 4, 2016 at 9:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .