SitePoint Sponsor |
|
User Tag List
Results 1 to 24 of 24
-
Dec 14, 2006, 20:24 #1
- Join Date
- Jan 2006
- Posts
- 221
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Need help please email function not working.
Hi all, I am having a problem but I am not sure why this Email function is not working. This is my script to send out a short newsletter to some people on the website. It pulls their email address if they have the newsletter feature enabled. When i run the script it says how many emails were sent. But the emails never go thru. I dont get any errors. Currently 9 emails should be sent and It says they were. But the emails never get delivered. If anyone can help me to figure out why the emails are not going thru I would appreciate it much. Thank all.
PHP Code:if(isset($_POST[s1]))
{
//get the subscribers info
$q1 = "select * from news_as where news = 'y' ";
$r1 = mysql_query($q1) or die(mysql_error());
while($a1 = mysql_fetch_array($r1))
{
$to = $a1[email];
$subject = $_POST[subject];
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/$a1[NewsletterType]; charset=iso-8859-1\n";
$headers .= "Content-Transfer-Encoding: 8bit\n";
$headers .= "From: $_SERVER[HTTP_HOST] <$aset[ContactEmail]>\n";
$headers .= "X-Priority: 1\n";
$headers .= "X-MSMail-Priority: High\n";
$headers .= "X-Mailer: PHP/" . phpversion()."\n";
if($a1[NewsletterType] == "plain")
{
$message = strip_tags($_POST[message]);
$message .= "\n\n========================\nTo unsubscribe, use this link:\n";
$message .= "$site_url/u.php?id=$a1[AgentID]";
}
else
{
$message = $_POST[message];
$message .= "<br><hr width=\"100%\" size=1 color=black>Click <a href=\"$site_url/u.php?id=$a1[NewsID]\">here</a> to unsubscribe.";
}
$message = stripslashes($message);
mail($to, $subject, $message, $headers);
$i++;
}
//add the message to the mail archive
$t = time();
$q1 = "insert into d_m_archive set
subject = '$_POST[subject]',
message = '$_POST[message]',
MailDate = '$t' ";
mysql_query($q1) or die(mysql_error());
echo "<center><b>$i emails have been successfully sent!</b></center><br>";
}
//get the subscribers number
$q1 = "select count(*) from news_as where news = 'y' ";
$r1 = mysql_query($q1) or die(mysql_error());
$a1 = mysql_fetch_array($r1);
if($a1[0] == '0')
{
echo "<br><center><font face=verdana size=2 color=red><b>You have no subscribers at your mailing list!";
exit();
}
?>
-
Dec 14, 2006, 21:39 #2
- Join Date
- Mar 2006
- Posts
- 6,132
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
use var_dump() or echo the variables involved in sending the mail.
var_dump() the call to mail()
turn up error reporting.
-
Dec 14, 2006, 21:45 #3
- Join Date
- Jan 2006
- Posts
- 221
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Clamcrusher, you know I am a newb, and whenever i post a new thread your advice is usually right on the money and I resolve alot of issues thanks to your advice. So thanks. I am not sure how to use vae_dump() the call to mail() feature.. I am sorry but can you please explain hot o add that into my code?
-
Dec 14, 2006, 22:14 #4
- Join Date
- Mar 2006
- Posts
- 6,132
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
var_dump(mail(...));
-
Dec 14, 2006, 22:19 #5
- Join Date
- Jan 2006
- Posts
- 221
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Ok this is what I got... I have no idea exactly what to do now..
Warning: mail() expects at least 3 parameters, 1 given in /home/content/a/l/p/a/html/siteadmin/Mail.php on line 16
NULL
Warning: mail() expects at least 3 parameters, 1 given in /home/content/a/l/p/a/html/siteadmin/Mail.php on line 16
NULL
Warning: mail() expects at least 3 parameters, 1 given in /home/content/a/l/p/a/html/siteadmin/Mail.php on line 16
NULL
Warning: mail() expects at least 3 parameters, 1 given in /home/content/a/l/p/a/html/siteadmin/Mail.php on line 16
NULL
Warning: mail() expects at least 3 parameters, 1 given in /home/content/a/l/p/a/html/siteadmin/Mail.php on line 16
NULL
Warning: mail() expects at least 3 parameters, 1 given in /home/content/a/l/p/a/html/siteadmin/Mail.php on line 16
NULL
Warning: mail() expects at least 3 parameters, 1 given in /home/content/a/l/p/a/html/siteadmin/Mail.php on line 16
NULL
Warning: mail() expects at least 3 parameters, 1 given in /home/content/a/l/p/a/html/siteadmin/Mail.php on line 16
NULL
Warning: mail() expects at least 3 parameters, 1 given in /home/content/a/l/p/a/html/siteadmin/Mail.php on line 16
NULL
line 16: var_dump(mail($a1['email']));
-
Dec 14, 2006, 22:32 #6
- Join Date
- Mar 2006
- Posts
- 6,132
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
give it all 4 parameters...
-
Dec 14, 2006, 22:34 #7
- Join Date
- Jan 2006
- Posts
- 221
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Okay how do I do that Clamcrusher?
-
Dec 14, 2006, 22:50 #8
- Join Date
- Oct 2003
- Location
- Florida
- Posts
- 264
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
The mail function takes at least 3 parameters. $to, $subject, $message, and $headers are all parameters.
This is what it should look like:
PHP Code:var_dump(mail($to, $subject, $message, $headers));
-
Dec 14, 2006, 22:55 #9
- Join Date
- Jan 2006
- Posts
- 221
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
This is what I got...
bool(true) bool(true) bool(true) bool(true) bool(true) bool(true) bool(true) bool(true) bool(true)
9 emails was sent!
-
Dec 14, 2006, 23:06 #10
- Join Date
- Mar 2006
- Posts
- 6,132
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
then you need to look at the 4 parameters and make sure they are appropriate.
consider sending a plain text hello world type email to test.
-
Dec 14, 2006, 23:19 #11
- Join Date
- Jan 2006
- Posts
- 221
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
How do I do that?
-
Dec 14, 2006, 23:27 #12
- Join Date
- Mar 2006
- Posts
- 6,132
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
var_dump() your variables.
see the documentation for the mail() function to see how to send a basic email. the point is: send a basic one to see if it works. it doesnt matter if the email is not what you want.
-
Dec 14, 2006, 23:30 #13
- Join Date
- Jan 2006
- Posts
- 221
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
ok It is echoing the correct email addresses that are saved in the database but one of them is mine and i never get the email
-
Dec 15, 2006, 00:29 #14
- Join Date
- Jan 2006
- Posts
- 221
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Ok i var dumped my variables here is what came up...:
string(7) "[email]" string(9) "[subject]" string(9) "[message]" string(14) "[ContactEmail]"
i var dumped them like this:
var_dump('[email]', '[subject]', '[message]', '[ContactEmail]');
-
Dec 15, 2006, 00:40 #15
- Join Date
- Mar 2006
- Posts
- 6,132
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
var_dump($var);
see the documentation...
-
Dec 15, 2006, 00:46 #16
- Join Date
- Jan 2006
- Posts
- 221
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Ok Clamcrusher, This is what I get.
string(19) "vinny917@yahoo.com" string(5) "test " string(97) "test ======================== To unsubscribe, use this link: http:www.netfreakz.com/u.php?id=24" string(196) "MIME-Version: 1.0 Content-type: text/stripslashes(plain); charset=iso-8859-1 Content-Transfer-Encoding: 8bit From: www.netfreakz.com <> X-Priority: 1 X-MSMail-Priority: High X-Mailer: PHP/4.3.11 "
-
Dec 15, 2006, 00:50 #17
- Join Date
- Mar 2006
- Posts
- 6,132
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
doesnt that look a bit funny to you?
-
Dec 15, 2006, 00:55 #18
- Join Date
- Jan 2006
- Posts
- 221
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
No should it? I am not sure what looks funny. Can you please help me Clamcrusher?
-
Dec 15, 2006, 00:56 #19
- Join Date
- Jan 2006
- Posts
- 221
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
this is how i vardumped:
var_dump($to, $subject, $message, $headers); did i even do it right?
when i var dump like this:
var_dump(mail($to, $subject, $message, $headers));
i get this:
bool(true) bool(true) bool(true) bool(true) bool(true) bool(true) bool(true) bool(true) bool(true)
-
Dec 15, 2006, 01:01 #20
- Join Date
- Mar 2006
- Posts
- 6,132
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
look at your content type and your from headers.
-
Dec 15, 2006, 01:14 #21
- Join Date
- Jan 2006
- Posts
- 221
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Ok i tried to fix it and this is what i get:
NULL string(4) "test" string(4) "test" NULL
-
Dec 15, 2006, 01:32 #22
- Join Date
- Jan 2006
- Posts
- 221
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Ok Clamcrusher I got it working but I had to pull out the line of code that was supposed to put the from email address into the email that goes out. This is the line of code it seems it wasnt pulling the email address out of the database. That was the problem <$aset[ContactEmail]>
-
Dec 15, 2006, 01:40 #23
- Join Date
- Mar 2006
- Posts
- 6,132
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
more like its undefined. had you turned up error reporting, it would have been obvious. continually, you do not turn up error reporting. errors are good. you want to see them. i dont know why i keep repeating myself over and over for you, seems like it does no good.
-
Dec 15, 2006, 01:43 #24
- Join Date
- Jan 2006
- Posts
- 221
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I am sorry I do not mean to frustrate you or make you feel like a broken record or answering machine. I didn't know how to imply the error reporting.
Bookmarks