Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #16913

Re: mail() function doesn't send email; mistakes in the code

Path csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From "J.O. Aho" <user@example.net>
Newsgroups comp.lang.php
Subject Re: mail() function doesn't send email; mistakes in the code
Date Fri, 5 Aug 2016 07:03:38 +0200
Lines 47
Message-ID <e0il1aFi4e1U1@mid.individual.net> (permalink)
References <0d3735d9-7ed7-46f6-81e2-98ec7d5e85e0@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 8bit
X-Trace individual.net iUQMmf6yE13+7LX9SjaWZQeEnggrBu2bo7359bxJqhcTcMniGa
Cancel-Lock sha1:7M06oX5+ojvSNznmtBsBz579PJ4=
X-Enigmail-Draft-Status N1110
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0
In-Reply-To <0d3735d9-7ed7-46f6-81e2-98ec7d5e85e0@googlegroups.com>
Xref csiph.com comp.lang.php:16913

Show key headers only | View raw


On 08/04/16 08:56, Alla wrote:
> Hello!
> 
> Please, take a look at the code below. I will be grateful for your help on why the code doesn't 
> work - I have tested it, but the email doesn't arrive. All other parts of the code are correct, 
> because these have been tested many times in other related files, i.e. those are templates. 
> 
>         if(mail($email, $email_subject, $email_body))
>         {               
>            // render form
>            render("email_link_form.php", ["email" => $email]);
>         }

The only time mail() will give you a false is when it fails to connect
to the SMTP service configured in the php.ini.

Most of the cases when mail do not arrive to the recipient, the mail has
been deemed as spam of either the SMTP service configured in the php.ini
or by the receiving SMTP server.

I do recommend you to set a proper from in the header, which you do not
have in this case.


>    // check if the user is logged in
>     if (isset($_SESSION["id"]))
>     {

You know you can use a form to allow the user to change their password,
just a have a field for their current password and a field for the new
password (you may want to have a confirm the new password too).


>         $salt = "3453#2K:90k≈“π631%380‘“HJK0D*7WPJ987NU";
>         // Create the unique user password reset key
>         $password = hash('sha512', $salt.$email);

If redirecting a user to a page, don't use something which is permanent
for the user, generate a random value instead, which will only be used
once, store it temporarily in a table together with the user id, so you
know who it is (only applies to users who ain't logged in, as you have
already the session for those who are logged in and do not need to use
temporarily tokens to know who they are).

-- 

 //Aho

Back to comp.lang.php | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

mail() function doesn't send email; mistakes in the code Alla <modelling.data@gmail.com> - 2016-08-03 23:56 -0700
  Re: mail() function doesn't send email; mistakes in the code "R.Wieser" <address@not.available> - 2016-08-04 12:39 +0200
    Re: mail() function doesn't send email; mistakes in the code Alla <modelling.data@gmail.com> - 2016-08-05 07:04 -0700
  Re: mail() function doesn't send email; mistakes in the code Jerry Stuckle <jstucklex@attglobal.net> - 2016-08-04 13:30 -0400
    Re: mail() function doesn't send email; mistakes in the code Alla <modelling.data@gmail.com> - 2016-08-05 07:07 -0700
  Re: mail() function doesn't send email; mistakes in the code Eli the Bearded <*@eli.users.panix.com> - 2016-08-04 20:27 +0000
    Re: mail() function doesn't send email; mistakes in the code Alla <modelling.data@gmail.com> - 2016-08-05 07:06 -0700
  Re: mail() function doesn't send email; mistakes in the code "J.O. Aho" <user@example.net> - 2016-08-05 07:03 +0200
    Re: mail() function doesn't send email; mistakes in the code Jerry Stuckle <jstucklex@attglobal.net> - 2016-08-05 10:24 -0400
    Re: mail() function doesn't send email; mistakes in the code Jerry Stuckle <jstucklex@attglobal.net> - 2016-08-05 10:26 -0400
      Re: mail() function doesn't send email; mistakes in the code "J.O. Aho" <user@example.net> - 2016-08-05 23:02 +0200
        Re: mail() function doesn't send email; mistakes in the code Jerry Stuckle <jstucklex@attglobal.net> - 2016-08-05 19:39 -0400

csiph-web