PHP Mail not working


#1

Hi,
I’m trying to create a reserved area, but my script doesn’t send the confirmation email with mail() function at the registration phase.
Why?
This is my registration file.
P.S.: The comments and the variables names are in Italian

<?php require('config.php'); if(isset($_POST['registra'])) { $user = (isset($_POST['user'])) ? trim($_POST['user']) : ''; // Metto nella variabile 'user' il dato inviato dal modulo, se non viene inviato d di default '' $pass = (isset($_POST['pass'])) ? trim($_POST['pass']) : ''; // Metto nella variabile 'pass' il dato inviato dal modulo, se non viene inviato d di default '' $mail = (isset($_POST['mail'])) ? trim($_POST['mail']) : ''; // Metto nella variabile 'mail' il dato inviato dal modulo, se non viene inviato d di default '' if (!get_magic_quotes_gpc()) { $user = addslashes($user); $pass = addslashes($pass); $mail = addslashes($mail); } if(strlen($user) < 4 || strlen($user) > 12) die('Nome Utente troppo corto, o troppo lungo'); elseif(strlen($pass) < 4 || strlen($pass) > 12) die('Password troppo corta, o troppo lunga'); elseif(!eregi("^[a-z0-9][_\\.a-z0-9-]+@([a-z0-9][0-9a-z-]+\\.)+([a-z]{2,4})", $mail)) die('Email non valida'); elseif(mysql_num_rows(mysql_query("SELECT user FROM utenti WHERE user = '$user' LIMIT 1")) == 1) die('Nome Utente non disponibile'); elseif(mysql_num_rows(mysql_query("SELECT mail FROM utenti WHERE mail = '$mail' LIMIT 1")) == 1) die('Questo indirizzo email risulta già registrato ad un altro utente'); else { $pass = md5($pass); $attivazione = ''; for($x=1; $x<=32; $x++) $attivazione.=rand(0,9); $attivazione = md5($attivazione); $message = 'Per attivare il Suo account deve visitare il seguente link:
Attiva account'; // Header dell'email, per madnarla in formato html $headers = "From: Tabella interrogati \\r\ "; $headers .= "Reply-To: noreply@tabellainterrogati.rf.gd\\r\ "; $headers .= "Return-Path: noreply@tabellainterrogati.rf.gd\\r\ "; $headers .= "Content-Type: text/html; charset=ISO-8859-1\\r\ "; mail($mail, 'Registrazione', $message, $headers); $strSQL = "INSERT INTO utenti (user,pass,mail,attivazione)"; $strSQL .= "VALUES('$user', '$pass', '$mail', '$attivazione')"; mysql_query($strSQL) OR die("Errore 003, contattare l'amministratore ".mysql_error()); header('Location: registrato.php'); exit; } } ?> Registrazione




#2

The code doesn’t display very well, so I uploaded it at this link: https://codeshare.io/5X8o7z
Thanks again


#3

Have you checked the FAQ article: https://infinityfree.net/support/email/php-mail


#4

@Admin said:
Have you checked the FAQ article: https://infinityfree.net/support/email/php-mail

Yes, but it isn’t working…


#5

@maicol07 said:

@Admin said:
Have you checked the FAQ article: https://infinityfree.net/support/email/php-mail

Yes, but it isn’t working…

Have you read the paragraph after the list of things to check?

@maicol07 said:
The code doesn’t display very well

By adding three backticks before the code and three after it, you can enter a code block.

like  this

#6

@Admin said:

@maicol07 said:

@Admin said:
Have you checked the FAQ article: https://infinityfree.net/support/email/php-mail

Yes, but it isn’t working…

Have you read the paragraph after the list of things to check?
Yes, just now

@maicol07 said:
The code doesn’t display very well

By adding three backticks before the code and three after it, you can enter a code block.

like  this

Thanks for the explanation, but I can’t edit the first post…


#7

Any news? How can I send email with PHP mail() function? Thanks


#8

@maicol07 said:
Any news? How can I send email with PHP mail() function? Thanks

The tutorial has the answer, please make sure to read it carefully. If there is any sentence which isn’t clear to you, ask it here, but I can’t answer a question if there is a FAQ article dedicated to answering that specific question.


#9

Hi,

I have this problem too.
I made a php Contact form, and I don’t know why it doesn’t working …
The name it’s “Contact.php” from the “40dezilepentruviataBucuresti” folder.

More shortly, my php code is this :

<?php

    if ($option == 'nimicAles') {
          echo "Trebuie sa alegeti un destinatar !";
       }
       else if ($option == 'CristianF'){
    	   $persoana_spre = mail_cristian;
       }
       
       
    $persoana_eu = $_POST['numeTu'];
    $mail_eu = $_POST['mailTu']; /* eu care trimit */
    $subiect = $_POST['SubiectTu'];
    $mesaj = $_POST['mesaj'];
    $mesaj = wordwrap($mesaj, 70, "\\r\

");

    if($_POST){
    	mail($persoana_spre,'40 de zile website - ' . $subiect, $mesaj, 'From: ' . $mail_eu);
    	$feedback = 'Mesaj trimis cu succes !';
    }
    ?>

and I checked and the whole code it’s working, exept that I don’t recived any mail.
I have to upgrate to premium to use php mail ?


#10

@Cristif92 said:
Hi,

I have this problem too.
I made a php Contact form, and I don’t know why it doesn’t working …
The name it’s “Contact.php” from the “40dezilepentruviataBucuresti” folder.

More shortly, my php code is this :

and I checked and the whole code it’s working, exept that I don’t recived any mail.
I have to upgrate to premium to use php mail ?

Did you read the FAQ article and everything which was said in this topic? Because the answer is already there.


#11

@Admin said:
Did you read the FAQ article and everything which was said in this topic? Because the answer is already there.

Yeap. I readed entirely

At the moment, you can only send registration and activation e-mails through PHP mail(). Outbound e-mails are filtered based on templates for registration, activation and confirmation e-mails. Other types of e-mail, like contact requests, newsletters, notifications, etc. will be dropped and not be delivered to your recipient.

I checked also the SendGrid and Mailjet options, and both are trials free.
Do you know others ? Or what are they ?

and why it would help me in the php developer webpage ? I don’t get it…

So in other words, if I want a contact mail in php, I must upgrade to premium …


#12

@Cristif92 said:

@Admin said:
Did you read the FAQ article and everything which was said in this topic? Because the answer is already there.

Yeap. I readed entirely

At the moment, you can only send registration and activation e-mails through PHP mail(). Outbound e-mails are filtered based on templates for registration, activation and confirmation e-mails. Other types of e-mail, like contact requests, newsletters, notifications, etc. will be dropped and not be delivered to your recipient.

I checked also the SendGrid and Mailjet options, and both are trials free.
Do you know others ? Or what are they ?

and why it would help me in the php developer webpage ? I don’t get it…

So in other words, if I want a contact mail in php, I must upgrade to premium …

If you want to be able to properly send e-mail from your website, you should use an external SMTP service to send it. The providers listed provide that for free. If you insist on using the PHP mail() function itself, yes, you do need to upgrade. But I can’t think of any reason why you would need to use PHP mail() function and cannot use SMTP.


#13