mail() problems

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
User avatar
HaVoC
Forum Commoner
Posts: 83
Joined: Sat Feb 07, 2004 7:20 am
Location: Smiths Falls, CA

mail() problems

Post by HaVoC »

I've gotten it to work, but for some reason it won't sent to hotmail accounts.

Is there something I need for it to be accepted or something i'm sending that I shouldn't have?

Code: Select all

<?php
			$sendto = "SELECT * FROM users WHERE user_newsletter = 'on'";
			$sendto = mysql_query($sendto);
			$subject = $_POST['subject'];
			
			$message = '<html>
					<body bgcolor="black" text="white" link="white" alink="white" vlink="white">';
			$message .= '<table width="100%" border="1" bordercolor="#b70000" cellspacing="0" cellpadding="0">
						<tr>
						 <td width="25%" height="75"></td><td width="25%"></td><td width="25%"></td><td width="25%"></td>
						</tr>
						<tr>
						 <td width="25%"></td><td rowspan="2" width="50%">';
			$message .= $_POST['message'];
			$message .= '</td><td width="25%"></td>';
			$message .= '	<tr>
						 <td width="25%"></td><td width="25%"></td>
						</tr>
						<tr>
						 <td width="25%" height="75"></td><td width="25%"></td><td width="25%"></td><td width="25%"></td>
						</tr>
					</table>
				</body>
				</html>';

			While ($sending = MySQL_fetch_array($sendto)){
				$recipient = $sending['user_name'];
				$remail = $sending['user_email'];
				$to = $remail;

				$headers = "MIME-Version: 1.0\r\n"; 
				$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
				$headers .= "To: {$recipient} <{$remail}>\r\n"; 
				$headers .= "From: Demon Lords Newsletter <noreply_demonlords@demonlords.stalkingtigers.org>\r\n";

				mail($to, $subject, $message, $headers); 
}

?>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

You may need Return-Path and Reply-To headers...
Deemo
Forum Contributor
Posts: 418
Joined: Sun Jan 18, 2004 11:48 am
Location: Washington DC

Post by Deemo »

its also possible that the accounts you are sending to have junk mail filters on and are sent to the Junk Mail folder
User avatar
HaVoC
Forum Commoner
Posts: 83
Joined: Sat Feb 07, 2004 7:20 am
Location: Smiths Falls, CA

Post by HaVoC »

Is there a special command for Reply-To?
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

no, you add it as a header.
User avatar
HaVoC
Forum Commoner
Posts: 83
Joined: Sat Feb 07, 2004 7:20 am
Location: Smiths Falls, CA

Post by HaVoC »

What'sReturn-Path used for?
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

It's used to return the message in case it can't be delivered ;)
User avatar
HaVoC
Forum Commoner
Posts: 83
Joined: Sat Feb 07, 2004 7:20 am
Location: Smiths Falls, CA

Post by HaVoC »

Ohh! On a big newsletter that could be bad! :P
Post Reply