...

View Full Version : php email not sending?!



jarv
03-10-2009, 05:07 PM
can someone please help with my PHP emailer?
the form submits and I get to thankyou.htm page after submission but I do not receive an email?!


<?php
$title = tidyInput($_POST['title']) ;
$first_name = tidyInput($_POST['first_name']) ;
$last_name =tidyInput( $_POST['last_name'] );
$company = tidyInput($_POST['company'] );
$job = tidyInput($_POST['job'] );
$email =tidyInput( $_POST['email']) ;
$tel = tidyInput($_POST['tel']) ;
$enquiry = tidyInput($_POST['enquiry']) ;
$domain = tidyInput($_POST['domain']) ;
$trademark = tidyInput($_POST['trademark']) ;
$channel = tidyInput($_POST['channel']) ;
$phishing = tidyInput($_POST['phishing']) ;

$message = "Name: ".$title." ".$first_name." ".$last_name."\n";
$message .= "Firma: ".$company."\n";
$message .= "Stellenbezeichnung: ".$job."\n";
$message .= "Email: ".$email."\n";
$message .= "Telefon: ".$tel."\n";
$message .= "Informationen: ".$enquiry."\n";
$message .= "Interessieren Domain Management: ".$domain."\n";
$message .= "Online Channel Protection: ".$channel."\n";
$message .= "Online Trademark Protection: ".$trademark."\n";
$message .= "AntiPhishing Solutions : ".$phishing."\n";
$message .= "Informieren : ".$consent."\n";


function tidyInput($text){
$cleanOutput = strtolower($text);
$cleanOutput = str_replace('\n', "", $cleanOutput);
$cleanOutput = str_replace(array('\r', '\n', '%0a', '%0d', 'content-type:', 'subject:', 'bcc:', 'to:', 'cc:', '\\'), "", $cleanOutput);
$cleanOutput = strip_tags($cleanOutput);
$cleanOutput = stripslashes($cleanOutput);
return $cleanOutput;
}


mail( "email@blah.com", "Mark Monitor Form", $message, "From: $email" );
header( "Location: thankyou.htm" );
?>

_Aerospace_Eng_
03-10-2009, 05:15 PM
Add this to the top of your code

ini_set('display_errors','1');
error_reporting(E_ALL);
Then change this

mail( "blah@domain.com", "Mark Monitor Form", $message, "From: $email" );

to this


$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: $first_name $last_name<$email>\r\n" .
"Reply-To: ".$email."";
mail( "blah@domain.com", "Mark Monitor Form", $message, $headers);

I also suggest you remove your email addresses from this thread to help prevent spam.

jarv
03-10-2009, 05:52 PM
Thanks, done that, now I get:


Notice: Undefined index: domain in D:\home\Default\marken-schutzonline.de\htdocs\sendmail.php on line 13

Notice: Undefined index: trademark in D:\home\Default\marken-schutzonline.de\htdocs\sendmail.php on line 14

Notice: Undefined index: channel in D:\home\Default\marken-schutzonline.de\htdocs\sendmail.php on line 15

Notice: Undefined index: phishing in D:\home\Default\marken-schutzonline.de\htdocs\sendmail.php on line 16

Notice: Undefined variable: consent in D:\home\Default\marken-schutzonline.de\htdocs\sendmail.php on line 28

Warning: mail() [function.mail]: SMTP server response: 501 Syntax error in parameters or arguments in D:\home\Default\marken-schutzonline.de\htdocs\sendmail.php on line 48

I was just looking into the mail(); function on my IIS server

this is what is in my php.ini file:

[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25

; For Win32 only.
;sendmail_from = me@example.com

; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path =

; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =

jarv
03-10-2009, 06:49 PM
all sorted now, just needed to activate the sendmail_from:

; For Win32 only.
;sendmail_from = me@example.com



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum