Jump to content

Emailing


Zepo.

Recommended Posts

This isnt working for some reason, and im not sure if you can email in loops like this......

 

Loop

$emailq=mysql_query("SELECT name,email FROM teams");
while(list($name,$email)=mysql_fetch_row($emailq)){

$email[toname]		="$name";
$email[toemail]		="$email";
$email[subject]		="$send[subject]";
$email[fromname]	="{$_SESSION['rights']}";
$email[fromemail]	="$config[sitemail]";
$email[replyname]	="$name";
$email[replyemail]	="$email";
$email[body]		="$send[body]";

email($email);
$sent.="Sending To $name..........Sent<br />";
}

 

Email Function

//E-Mail Function
function email($email){
mail("$email[toname] <$email[toemail]>","$email[subject]","$email[body]", "From: $email[fromname] <$email[fromemail]>\nReply-To: $email[replyname] <$email[replyemail]>\nContent-type: text/plain\nX-Mailer: PHP/" . phpversion());
}

 

 

No errors.

Link to comment
Share on other sites

Your function is calling a variable that gets defined in the actual code try:

 

<?php
$emailq=mysql_query("SELECT name,email FROM teams");
function email($email){
mail("$email[toname] <$email[toemail]>","$email[subject]","$email[body]", "From: $email[fromname] <$email[fromemail]>\nReply-To: $email[replyname] <$email[replyemail]>\nContent-type: text/plain\nX-Mailer: PHP/" . phpversion());
}
while(list($name,$email)=mysql_fetch_row($emailq)){

$email[toname]		="$name";
$email[toemail]		="$email";
$email[subject]		="$send[subject]";
$email[fromname]	="{$_SESSION['rights']}";
$email[fromemail]	="$config[sitemail]";
$email[replyname]	="$name";
$email[replyemail]	="$email";
$email[body]		="$send[body]";

email($email);
$sent.="Sending To $name..........Sent<br />";
}
?>

Link to comment
Share on other sites

You have alot of code there that would be generating syntax warnings, and also absolutely no error handling.

 

<?php

if ($emailq = mysql_query("SELECT name,email FROM teams")) {
  if (mysql_num_rows($emailq)) {  
    while(list($name,$email)=mysql_fetch_row($emailq)){

      $email['toname']		=$name;
      $email['toemail']		=$email;
      $email['subject']		=$send['subject'];
      $email['fromname']	={$_SESSION['rights'];
      $email['fromemail']	=$config['sitemail'];
      $email['replyname']	=$name;
      $email['replyemail']	=$email;
      $email['body']		=$send['body'];

      if (email($email)) {
        $sent.="Sending To $name..........Sent<br />";
      }
    }
  }
}

 

Next, your email function should look like....

 

<?php

function email($email){
  return mail("{$email['toname']} <{$email['toemail']}>",$email['subject'],$email['body'], "From: {$email['fromname']} <{$email['fromemail']}>\nReply-To: {$email['replyname']} <{$email['replyemail']}>\nContent-type: text/plain\nX-Mailer: PHP/" . phpversion());
}

?>

Link to comment
Share on other sites

Also, ps. You are getting no errors becuas eyou obviously have error reporting switched off, or set too low. Otherwise all those syntax warnings I pointed out would show up.

 

Make sure error reporting and display errors are on while you develop your scripts.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.