mail() '-' problem

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I have I problem with a function that send out mail. It works with
every email-adresses except those containing "-". I have severeal
groups of emails, and it send mail to every group except one, who has a
mail adress with "-". In this group, no one recieve mail.


if (isset($_POST['send_post'])) {

    $sql = "SELECT * FROM grupper";
    $resultat = mysql_query($sql, $tilkobling);
    while ($rad =mysql_fetch_array($resultat) ) {
        if (isset($_POST[$rad['kode']])) {

    if (!empty($epostgruppe[1])) {
       while (list($nokkel, $kode) = each($epostgruppe)) {
        if ( !empty($kode)) {
            $sql = "SELECT * FROM brukere WHERE tilgang LIKE '%".$kode."%'";
            //echo $sql;
            $resultat = mysql_query($sql, $tilkobling);
            while ($rad =mysql_fetch_array($resultat) ) {
                if (strstr($rad['email'],"@")) {
                    if (empty($epostliste)) {

                    } else {
                        if (!strstr($epostliste,$rad['email'])) {
                            $epostliste=$epostliste  . "," . $rad['email'];

    if (!empty($_POST['andre']) && strstr($_POST['andre'],"@")) {
        $epostliste=  $_POST['andre'] . "," . $epostliste;

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



    echo "Epost sendt...";

    mail($epostliste, $emne, $beskjed, $headers);


Re: mail() '-' problem

Another related question. Is there a way of getting a mail delivery
report. For instance if an adresse do not exist

Re: mail() '-' problem

*** torbs escribió/wrote (21 Nov 2005 05:16:01 -0800):
Quoted text here. Click to load it

You've posted about 60 lines of code. You really should try to isolate the
line where the error happens. A simple echo or var_dump() with a trailing
exit() will help.

-+ Álvaro G. Vicario - Burgos, Spain
++ es mi sitio para programadores web
+- es mi web de humor libre de cloro

Re: mail() '-' problem

The error is within the mail() function. I just posted the code so
people could see how the email where retrieved - from an SQL -query,
and how I send it. There is no error in my code. I want to know wheter
there is an workaround for email adresses containing the hyphen "-".

Site Timeline