LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-03-2011, 02:24 PM   #1
countrydj
Member
 
Registered: Jun 2009
Location: Preston, England
Distribution: Centos 6
Posts: 127

Rep: Reputation: 1
Problem with PHP mail()


Hi Guys...

I have a problem that I just done understand.
This is the code that I am using:
Code:
	# SEND EMAIL

//	$to      = 'ann@in-uk.co.uk';
	$to      = 'dave@swarbrick-racing.co.uk';
	$subject = "Web site Enquiry";

	$headers = "From: $email ($name)\r\n";
	$headers .= "Bcc: jc@ukzone.com\r\n";
   	$headers .="Reply-To: $name <$email>\r\n";
   	$headers .="X-Mailer: PHP/ . phpversion()";

	$messages = "Message from:  $name ($email) on $date_time\n\n";
	$messages .= "-----------------------------------------------------------------------------------------------------------------------------------\n\n";
	$messages .= "Remote IP: $remote_ip\n";
	$messages .= "Referer: $referer\n\n";
	$messages .= "Name: $name\n\n";
	$messages .= "Country: $country\n\n";
	$messages .= "Selection: $selection\n\n";
	$messages .= "Message:\n";
	$messages .= "$message\n\n";
	$messages .= "-----------------------------------------------------------------------------------------------------------------------------------\n\n";
	$messages .= "HTTP_USER_AGENT: $client\n\n";
mail($to, $subject, $messages, $headers);
The problem that I have is that the code will send Bcc when I have the main recipient as:
Code:
$to      = 'dave@swarbrick-racing.co.uk';
but it will NOT send Bcc when the main recipient is:
Code:
$to      = 'ann@in-uk.co.uk';
Has anybody got any ideas why this should happen ???

Any suggestions will be welcome.

John C
 
Old 11-04-2011, 10:47 AM   #2
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,453

Rep: Reputation: 447Reputation: 447Reputation: 447Reputation: 447Reputation: 447
Hi

The "From" in the headers in incorrect. It could be that different email system differs on what they do. Some maybe ignore the rest of the headers, and some maybe just ignore the from line. Not sure, but it should be like:
PHP Code:
$headers "From: $name <$email>\r\n"
 
Old 11-04-2011, 11:31 AM   #3
countrydj
Member
 
Registered: Jun 2009
Location: Preston, England
Distribution: Centos 6
Posts: 127

Original Poster
Rep: Reputation: 1
Hi Guttorm
Many thanks for taking the time to try and help me.
Quote:
The "From" in the headers in incorrect. It could be that different email system differs on what they do. Some maybe ignore the rest of the headers, and some maybe just ignore the from line. Not sure, but it should be like:
PHP Code:
$headers "From: $name <$email>\r\n"
or
PHP Code:
$headers "From: $email ($name)\r\n"
I don't think that it makes any difference which way round it goes.
I have always used the way in my original code.

However, I sussed out the problem, eventually.

I was using two email addresses that shared the same mailbox.

The code worked fine with two different emasil addresses with different mailboxes.

Thanks agian..

John C
 
Old 11-04-2011, 05:18 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Moved: This thread is more suitable in <PROGRAMMING> and has been moved accordingly to help your thread/question get the exposure it deserves.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Mail() Problem w/ Sendmail jusme Linux - Software 6 08-18-2012 02:35 PM
PHP - Mail.php and Mail/mime.php issues LVsFINEST Linux - Server 1 02-08-2009 05:44 PM
Mail problem with php apache shritesh Linux - Server 1 11-02-2006 09:27 AM
php mail problem czarherr Programming 4 09-07-2005 11:03 PM
php mail() problem sashhoney Linux - Software 3 09-30-2003 05:06 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:04 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration