Mail () ... Doubt


#1

I have an contact form that uses the php command mail()…
I’ts all working now, after a little bit of working, but there is one thing that i can’t change…

When anyone fills the form and send it to the desired contact, it keeps coming with the same from address: matrix_akira@erida.dreamhost.com

Is there any way of change it ?! It does’nt need to be everytime changeable. But i just don’t want it to be: matrix_akira@erida.dreamhost.com

Hope you can help… :wink:

CyA ! …


#2

Have you read Dreamhost’s Wiki entry on php mail() function?

Specifically the “Advanced example”:

[code]<?php
$to = "somebody@example.com";
$subject = “Nonsensical Latin”;

// compose headers
$headers = “From: webmaster@example.com\r\n”;
$headers .= “Reply-To: webmaster@example.com\r\n”;
$headers .= “X-Mailer: PHP/”.phpversion();

// compose message
$message = “Lorem ipsum dolor sit amet, consectetuer adipiscing elit.”;
$message .= " Nam iaculis pede ac quam. Etiam placerat suscipit nulla.";
$message .= " Maecenas id mauris eget tortor facilisis egestas.";
$message .= " Praesent ac augue sed enim aliquam auctor. Ut dignissim ultricies est.";
$message .= " Pellentesque convallis tempor tortor. Nullam nec purus.";
$message = wordwrap($message, 70);

// send email
mail($to, $subject, $message, $headers);
?>
[/code]
More specifically, the “From” part of the header. That should fix your problems.

Cheers,
Karl

web design, development & seo by DigitalVibe


#3

I’ve tried this too… But it still don’t work… The Emails keep coming as matrix_akira@erida.dreamhost.com

If you want to see the code page i’ll post it here…

Tnks for the help…

Sendemail Script <?php $contato = $_POST['contato']; $nome = $_POST['nome']; $tel = $_POST['tel']; $cel = $_POST['cel']; $estado = $_POST['estado']; $cidade = $_POST['cidade']; $mailfrom = $_POST['mailfrom']; $dados = $_POST['dados']; if(!$mailfrom == "" && (!strstr($mailfrom,"@") || !strstr($mailfrom,"."))) { echo "

Volte e digite um email valido.

\n"; $badinput = "

O Contato não foi enviado.

\n"; echo $badinput; die ("Retorne..."); } if(empty($nome) || empty($mailfrom) || empty($tel) || empty($dados)) { echo "

Os campos Nome, Email, Telefone e Comentário são obrigatórios.

\n"; die ("Retorne..."); } $subject = $contato; $dados = stripcslashes($dados); $message = "Aos cuidados de: $contato \n"; $message .= "Mensagem: $dados \n"; $message .= "De: $nome ($mailfrom)\n"; $message .= "Celular: $cel \n"; $message .= "Telefone: $tel \n"; $from = "De: $mailfrom \r\n"; $to = $contato; $headers .= "From: kawamac@kawamac.com.br\r\n"; $headers .= "Reply-To: kawamac@kawamac.com.br\r\n"; $headers .= "X-Mailer: PHP/".phpversion(); mail($to, $subject, $message, $from, $headers); ?>

Data: <?php echo $todayis ?>
Obrigado : <?php echo $nome ?> ( <?php echo $mailfrom ?> )

Contato: <?php echo $contato ?>


Mensagem:

<?php $notesout = str_replace("\r", "
", $dados); echo $notesout; ?>

<?php echo $to, "
", "
", $subject, "
", $message, "
", $from ?>




Voltar para o WebSite


#4

Remove the $from, bit from the mail line… headers replaces it completely.

You should have:

mail($to, $subject, $message, $headers);
That should do the trick.

Also bear in mind that in the confirmation “echo” you’re displaying the $from var, however in the actual email, you’re sending it to a fix address in the "$header = ‘From:’ " part.

Cheers,
Karl

web design, development & seo by DigitalVibe


#5

I don’t know how to thank you…

It’s Working now.
I’ve made some changes and now it’s great…

Thanks again…
CyA !!!