Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How many email's is php_mail() good for? 1

Status
Not open for further replies.

34534534534555

IS-IT--Management
Jan 8, 2003
240
GB
I have a mailing list that i think is going to grow to thousands of contacts.

I have just programmed a php mail() solution.

It has been suggested i use phpmailer() or PEAR but i can't install either of these on my host!?

I am using a simple loop to send the email, HOW MANY, approximately until this falls over, is there a workaround?

TIA
 
Your first statement is not true.
You can just put the PHPMailer class in any subfolder in your site. A simple require() statement will include it.
Go that way, it's easier.
Your host has no control over what classes/scripts you have in your site (as long as it doesn't violate policies etc.).
 
Sometimes it is good to be wrong! Thanks for pointing that out.

I have now upped phpmailer, but i am getting:

Warning: open_basedir restriction in effect. File is in wrong directory in /home/httpd/vhosts/hostname/httpdocs/dbdev/lib/phpmailer/class.phpmailer.php on line 460
There was a problem sending this mail!

line 460 is: include_once($this->PluginDir . "class.smtp.php");
but i don't know what's wrong as it is in the default place?

obv. i have changed hostname to my domain.

Secondly, when i am sending email using what is working, that is my mail() script i am getting very different formatting, depending on which email address receives it, sometimes there are no line feeds sometimes there are many. So included nl2br but then i get <br /> in the emails? I am getting the text from a form

TIA


| Feedback is always appreciated as this will help to further our knowledge as well |
 
The PHPMailer include file itself includes other files. The open_basedir() error on a line in class.phpmail.php tells me that the file PHPMailer is trying to include is outside the limits to file operations set by your server administrator. See the output of phpinfo() to see in what directories your scripts may perform file operations.



The problem with the hard returns is caused by differences in operating systems, mail clients, and how they interpret newlines. Unix-like OSes use linefeed ("\n") for a new line in a file. MS OSes use carriage return-linefeed ("\r\n"). Macs use just carriage return ("\r"). I would use the MS-standard way, as that is what the RFCs that define SMPT specify, so you're more likely to see consistent results.

Using nl2br() won't work unless your script is sending HTML email, as <br> or <br /> only have meaning in HTML.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Thanks for your reply,

I am now sending HTML email so that i can use nl2br(), if anyone wants to know, to send HTML email include these in your headers:

Code:
$headers = 'MIME-Version: 1.0' . "\r\n" .
'Content-type: text/html; charset=iso-8859-1' . "\r\n";


| Feedback is always appreciated as this will help to further our knowledge as well |
 
Damn it!

All i need is to be able to send email that when the form has <enter>'s in it, they need to be in the email!!

With those headers, when using nl2br() it works fine for hotmail and my ISP but fails with AOL and NTL..

Without the headers, it fails with hotmail and my ISP and works with AOL and NTL....

How do i get around this?

Here's my code:
Code:
$subject = $HTTP_POST_VARS['subject'];
$message = $HTTP_POST_VARS['message'];
$town = $HTTP_POST_VARS['town'];
$headers = 'From: webmaster@' . $_SERVER['SERVER_NAME'] . "\r\n" . 
'Reply-To: webmaster@' . $_SERVER['SERVER_NAME'] . "\r\n" .
'X-Mailer: PHP/' . phpversion() . "\r\n" .
'MIME-Version: 1.0' . "\r\n" .
'Content-type: text/html; charset=iso-8859-1';

nl2br($message);

$sql = "SELECT emailaddress FROM user WHERE town = '$town'";
	
$query = mysql_query($sql) or die (mysql_error());

while ($myrow = mysql_fetch_assoc($query)) {
	mail ($myrow['emailaddress'], $subject, $message, $headers);
	$run +=1;
	//pause every 20 emails for a breather
	if ($run >= 20) {
		sleep(4);
		$run = 0;
	}
	
}

I'm not using PHPmailer yet because i still can't work out that error and my host is playing the i don't exist game!!

Help is greatly appreciated.


| Feedback is always appreciated as this will help to further our knowledge as well |
 
Use the 5th parameter to the mail() function and set it to be the same as the "From:" header replacing the "From: " with "-f ".

Example:
Code:
$fifth = '-f webmaster@' . $_SERVER['SERVER_NAME'];
Code:
mail ($myrow['emailaddress'], $subject, $message, $headers, $fifth);

If you are using a shared server, look at the full headers of the email you're sending. You will probably see a header like "from nobody@your.hosted.domain". Using the 5th parameter will make the "From:" and "from" header match.

Ken
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top