mail() not mailing.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
granite
Forum Commoner
Posts: 44
Joined: Mon Feb 09, 2009 10:52 am

mail() not mailing.

Post by granite »

Hello there, dudes!!

Well, I've got a problem: I'm using a form to send emails to a mailbox using mail(), but they're not arriving.

I'm sure that the mailbox exists, and that the function mail() returns true, that is, the e-mail was supposedly sent. Also, if I use my gmail account as addressee, the message arrives normally.

Do you have any idea of why it's not arriving?

Thanks.
Last edited by granite on Mon Apr 27, 2009 11:00 am, edited 1 time in total.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: mail() not mailing.

Post by Benjamin »

Can you post your code please?
granite
Forum Commoner
Posts: 44
Joined: Mon Feb 09, 2009 10:52 am

Re: mail() not mailing.

Post by granite »

Code: Select all

$para     = "sac at bioseiva dot com dot br";
$nome    = $_POST['nome'];
$mensagem  = $_POST['mensagem'];
 
$msg = "Mensagem enviada apartir de $site_cliente \r\n \r\n"; 
$msg.= "Nome:     $nome \r\n";
$msg.= "Endereco: $endereco \r\n";
$msg.= "Telefone: $telefone \r\n";
$msg.= "Celular:  $celular \r\n";
$msg.= "E-mail:   $email \r\n \r\n";
$msg.= "Mensagem: $mensagem \r\n \r\n";
$msg.= "IP:       $ip \r\n";
 
$msg2= "$nome, esta é uma mensagem de resposta automática e não deve ser respondida.\r\n$nome_cliente agradece sua visita ao site $site_cliente. Retornaremos o mais breve possivel.\r\n";
$msg2.= "$nome_cliente\r\n";
$msg2.= "$site_cliente";
 
$headers = "From: $nome <$email>";
$headers2  = "From: $nome_cliente <$para>";
 
if(mail($para,"Talk to Us - $nome",$msg,$headers)){
      @mail($email,"Talk to Us - $nome_cliente",$msg2,$headers2);
      ?>
      <script>
           alert('<?php echo $nome ;?>, your message was sent.');
           location.href='http://www.bioseiva.com.br';
      </script>
      <?php 
}else{ ?>
      <script>
           alert('<?php echo $nome ;?>, sorry, your message could not be sent.');
           location.href='http://www.bioseiva.com.br';
      </script> 
<?php 
} ?>
granite
Forum Commoner
Posts: 44
Joined: Mon Feb 09, 2009 10:52 am

Re: mail() not mailing.

Post by granite »

Anyone?
Sanjay2011
Forum Newbie
Posts: 1
Joined: Wed Apr 29, 2009 5:45 am

Re: mail() not mailing.

Post by Sanjay2011 »

First use this headers content

Code: Select all

 
// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
 
// Additional headers
$headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";
 
If same problem after using this code then you have to use smtp. Search with keyword mail smtp you will get result.
Last edited by Benjamin on Tue May 12, 2009 2:15 pm, edited 1 time in total.
Reason: Added [code=php] tags.
granite
Forum Commoner
Posts: 44
Joined: Mon Feb 09, 2009 10:52 am

Re: mail() not mailing.

Post by granite »

Hey, thanks you very much.

I had three sites with this problem. Your suggestion helped me to fix two of them. The other one, however, is still not sending the emails.

Alright, I'm gonna goolgle to try to solve this.

Thanks!! :o
Post Reply