473,219 Members | 1,890 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,219 software developers and data experts.

mail-form php

Hi everyone!

I have a problem with php. I guess I am tired because I sure this is
simple, but I just can't make a simple mailscript work. I have to pages.
One htm and one php. Here's the code:

<link rel="stylesheet" href="../css/style.css">

<form method="post" action="send.php">
Namn:<br><input name="name" type="text" size="30"><br><br>
Email:<br><input name="email" type="text" size="30"><br><br>
&Auml;rende:<br><input name="subject" type="text" size="30"><br><br>
Meddelande:<br><textarea name="msg" cols="25"
<input type="reset" value="Reset">&nbsp;<input type="submit"

<title>Kontakta oss</title>
<link rel="stylesheet" href="../css/style.css">


$to = "cl*********@telia.com"; //
$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$msg = $_POST['msg'];
$sub = "form to mail";
$messub = "Subject: ".$subject."\n";
$mesmsg .= "Message: ".$msg."\n";
$mesname .= "Name: ".$name."\n";
$mesemail .= "Email: ".$email."\n";
if(empty($name) || empty($email) || empty($subject) || empty($msg)) {
echo " <h3>Du m&aring;ste fylla i alla f&auml;lt.</h3>";
$email)) {
print " <h3>Din email är felaktig.</h3>";
} else {
mail('$to', $sub, $messub, $mesmsg, $mesname, $mesemail);
print " <h3><center>Tack ".$name." f&ouml;r att du kontaktar

Can anyone tell me what I am doing wrong?

Sep 14 '05 #1
3 2572
Yvonne wrote:
Hi everyone!

I have a problem with php. I guess I am tired because I sure this is
simple, but I just can't make a simple mailscript work.

When posting on a NG, you should really say more than just "I can't
make it work", so we've got something to go on.

Which bit doesn't work? Do you get any error messages? Have you tried
putting in any diagnostics, e.g. echoing the various $_POST fields,
function return values, to see what's going on?



Sep 14 '05 #2
$messub = "Subject: ".$subject."\n";
$mesmsg .= "Message: ".$msg."\n";
$mesname .= "Name: ".$name."\n";
$mesemail .= "Email: ".$email."\n"; mail('$to', $sub, $messub, $mesmsg, $mesname, $mesemail);

Please read the documentation for the mail() function
<http://www.php.net/manual/en/function.mail.php> and don't make up your
own protocol.

Specifically: $to does not need single quotes; the 3rd parameter is
supposed to be the message body, not the subject; the 4th parameter is
extra headers, not the message body; the 5th parameter is usually
unused; the extra headers MUST include a "From:" header; none of the
headers are called "Subject:", "Message:", "Name:" or "Email:".

Try: mail( $to, $sub, $msg, "From:$email" );


Sep 14 '05 #3
On 2005-09-14, Yvonne <cl*********@telia.com> wrote:
I have a problem with php. I guess I am tired because I sure this is
simple, but I just can't make a simple mailscript work. I have to pages.
One htm and one php. Here's the code:

Do you know what happens when (with the headers) someone sends you date with \r\n in where
you don't expect it?

Met vriendelijke groeten,
Tim Van Wassenhove <http://timvw.madoka.be>
Sep 14 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Merijn Boom | last post by:
Hi there, I'm trying to create an html mail with embedded pictures in it. I run perl on Windows and Red Hat but I cannot get your module (Mail::Sender) to work. I'm just trying to run the...
by: Trond A. S. Andersen | last post by:
Hi, all! I'm trying to use the System.Web.Mail. "package" combinded with System.Web.Mail.SmtpMail in order to send MS Excel spreadsheets attached to mail messages. However, sending one single...
by: Phil Mc | last post by:
Hi has anyone come accross the problem.... with referance to System.Web.Mail.MailMessage and System.Web.Mail.SmtpMail THIS WORKS FINE mail=new MailMessage(); mail.From =...
by: RN | last post by:
I am tired of sending mail from the built-in SMTP service for so many reasons (errors are nondescriptive in the event log, it doesn't let me control which IP address it sends from, and it...
by: antonyliu2002 | last post by:
I've set up the virtual smtp server on my IIS 5.1 like so: 1. Assign IP address to "All Unassigned", and listen to port 25. 2. Access Connection granted to "". 3. Relay only allow...
by: J Huntley Palmer | last post by:
How may I setup a proper HTML mail message with embedded href links using PHP, that follows all the MIME rules? Any examples or links would be appreciated. Thanks!
by: William Connery | last post by:
Hi, I have a small python program with e-mail capabilities that I have pieced together from code snippets found on the internet. The program uses the smtplib module to successfully send an...
by: clevrmnkey | last post by:
I've had nothing but trouble from the System.Net.Mail objects, but I finally need to make them work, and I can't for the life of me see what I'm doing wrong. I pared back my mail transaction to...
by: cover | last post by:
I'm using PHP 5 at home w/Apache & MySQL on a test system where I write through a form to a database and also send an email to people on a drop down list. Purpose for this is an electronic log at...
by: mikek12004 | last post by:
Before posting here I google it and saw ablut 30 pages for a solution so I pretty much excluded the obvious things. The code is <?php //now to send the mails to seller...
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.