Forum Moderators: coopster
$client_to = $_POST['email_to'];
$subject = $_POST['email_subj'];
$message = create_msg();
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\n";
$headers .= "X-Priority: 3\n";
$headers .= "X-MSMail-Priority: Normal\n";
$headers .= "X-Mailer: php\n";
$headers .= "From: \"EMAIL\" <email@test.co.uk>\n";
$headers .= "Return-Path: email@test.co.uk\n",
$headers .= "Return-Receipt-To: email@test.co.uk\n"
return mail($client_to, $subject, $message, $headers);
I have been testing it, for some reason I can get it to send to my home email account but it wont send to my work email
Any help guys?
$headers = "From: \"".$from_name."\" <".$from_email.">\n";
$headers .= "To: \"".$to_name."\" <".$to_email.">\n";
$headers .= "Return-Path: <".$from_email.">\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: text/HTML; charset=ISO-8859-1\n";
It's been a while since I've used it, but I believe the formatting of the 'from' and 'to' headers is particularly important. I've also read that the inclusion of some X headers can be a problem, so best to leave them out unless you have a very good reason not to.
If you're sending from a Windows box, \n linefeeds should be replaced with Windows linefeeds.
Is it necessary to have a TO header, as you already declare the TO email address and place it in the mail() function
As well as that, like I said it sends the email through to my home email but not my work email. Could this be caused the content of the actual email and spam filters being used at work?
Thanks
It's a very serious problem. Your contact/email form can be used to send spam-emails to hundreds or thousands. Not only annoying, but your domain risks being banned/shut down.
[edited by: ergophobe at 4:51 pm (utc) on Sep. 25, 2005]
[edit reason] made link active [/edit]
Would this still apply if I use variables for the 'FROM' part of the header?
I've copied in my new script:
$from_email = "test@test.co.uk";
$from_name = "TEST EMAIL";
//headers for the email
$headers = "From: \"".$from_name."\" <".$from_email.">\n";
$headers .= "Return-Path: <".$from_email.">\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: text/HTML; charset=ISO-8859-1\n";
// subject for email
$subject = stripslashes($_POST['email_subj']);
$sql = "select * from test_email_add";
connect_db();
$res = mysql_query($sql);
$no_res = mysql_num_rows($res);
$counter = 0;
while ($counter < $no_res) {
$row = mysql_fetch_array($res);
// recipients pulled out from sql query
$client_to = stripslashes($row['test_email']);
// personalised message
$message = create_msg(stripslashes($row['test_name']));
mail($client_to, $subject, $message, $headers);
$counter++;
}
Would something like this be vulnerable?
My code was originally used for mass-mailing from a database. No forms, and register globals was off. If you hook up any script - email or otherwise - to the outside world without comprehensively validating input server-side then you're asking for trouble.
$client_to = $_POST['email_to'];
$subject = $_POST['email_subj'];
Previously I was using a form, but this was just to test to see if I was able to send mail but even this was on a secure server where the client had to be logged in to be able to access the webmail page
I've now changed it to have a form but all this is button which sends the mail which is already embedded in the php script
Apologies
Another nubee here but with the exact same problem which is doing my head in big time.
I can send a confirmation email to an admin address on the server. No probs - comes through every time - although the Return-Path is always 'nobody@...server'. I wonder if this is the problem? But the email NEVER comes through on a test using my pop3 accounts - with one exception (Tiscali.co.uk) who add anti-abuse headers to the mail.
I have searched the forums and tried all the recommendations but with no joy.
This is DEFINITELY NOT (in my case) a $variable value problem as I eliminated that by actually hard-coding one of my pop3 email addresses and the mail still never came through.
Contacted the hosting company (US) and they say it has nothing to do with the server settings, nor Exim4 - it is my script and that 'nobody@server..' will NOT cause this error.
So I am now totally confused!
Can anybody help me please? Getting quite desperate!
Here's a snippet of my code :-
$returnpath & $refid are previously declared in www......com format.
$subject = "Registration confirmation from $refid";
$Enquiry = "Hello " . $Name . ",";
$Enquiry.= "\n\nThank you for registering your details with " . $refid;
$Enquiry.= "\n\nYou may now log ...blah blah blah.... ";
$Enquiry.= "\n\nYour username is : " . $email;
$Enquiry.= "\n\nAnd your password has been set to : " . $pw;
$headers = "From: www.mydomain.com\r\n";
$headers .= "X-Sender: www.mydomain.com\r\n";
$headers .= "X-Mailer: PHP\r\n"; // mailer
$headers .= "X-Priority: 1\r\n"; // Urgent message!
$headers .= "Return-Path: $returnpath\r\n"; // Return path for errors
mail ($email, $subject, $Enquiry, $headers);
I have changed the domain name for obvious reasons!
I just do not understand why the emails come through to some accounts and not others.
Thanks for any light that can be thrown on this!
Underdog (Blacklab).
Matthijs - FYI, there is a "Supporters Forum" that is for subscribers only.