Email using form

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
ibluewave
Forum Newbie
Posts: 3
Joined: Fri Dec 10, 2004 12:04 am

Email using form

Post by ibluewave »

I had my email working fine on my site and now it stopped. Hosting provider said it may have something to do with line feeds. Anyways, here is the most recent code that I have tried

$visitormail is submitted from the form

Code: Select all

<?php
				
$myemail = "test@abccompany.com"; 
		
$subject = "Visitor Mail";
				
$message = " Message: $notes\n
";
$to = "To: $myemail\r\n";
$from = "From: $visitormail\r\n";
				
mail($from, $subject, $message, $to ); 
				
?>
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

I suggest you google around a bit, or just search this forum.

There must be a couple of examples on how to send mail.
for as far as i can see there aint much wrong with the code, but there is missing rather a few details. targeting for headers and suchs.
ibluewave
Forum Newbie
Posts: 3
Joined: Fri Dec 10, 2004 12:04 am

Post by ibluewave »

I'm all googled out! I will search the forum more but could you possibly elaborate on the use of headers?
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

Not that i mind but.. u should use google a bit differant than :)

Code: Select all

/* subject */
$subject = "mail subject:";

/* message as html ???*/
$message = '<html><body>something in here</body></html>';

/* To send HTML mail, you can set the Content-type header. */
$headers  = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: Who? <who?@mail.com>\r\n";
$headers .= "X-Sender: whosends?@mail.com\r\n";
$headers .= "X-Mailer: PHP\r\n";
$headers .= "X-Priority: 1\r\n";
$headers .= "Return-Path: whoget_bad_mail_back?@mail.com\r\n";
//$headers .= "To: You? <who?@mail.com>\r\n";


mail($mail_adress, $subject, $message, $headers);
U will need to check this, and edit some :) but besides that it should work
ibluewave
Forum Newbie
Posts: 3
Joined: Fri Dec 10, 2004 12:04 am

Post by ibluewave »

Thanks... unfortunately its a no go. I've tried over 30 different scripts off of google and from this forum with no luck. I'm thinking that it is something out side of the code that has to do with the mailserver? Any ideas?
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

Nope sorry, as i said before i dont see much wrong with tthe code just missing alot.

Try the provider again. If that fails, just use mailto:link@mail.com
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Post by Joe »

Try:

Code: Select all

<?php
$myemail = "test@abccompany.com";
$subject = "Visitor Mail";
$message = "Message here...";

$from = "webmaster@".$_SERVER['SERVER_NAME'];

mail($myemail, $subject, $message,"From: $from\r\n");          
?>
Post Reply