Page 1 of 1

Why is my mail not sent?

Posted: Wed Jan 28, 2009 4:53 am
by meddiecap
Hi,

I don't know why my emails are not being sent.

I got this code:

Code: Select all

 
<?php 
session_start();
error_reporting(E_ALL);
 
    require_once "inc_connect.php";
    require_once "swift/lib/Swift.php";
    require_once "swift/lib/Swift/Connection/SMTP.php";
 
    $sql = $_SESSION["sql"];
    // klanten means customers
    $res_klanten = mysql_query($sql) or die(mysql_error());
 
        // Send mail
        
        // Make instance of PHPMailer class
        // titel means title
        $titel = $_POST['emailtitel'];
        echo "<b>Titel: </b>".$titel."<br />";
        echo "<hr />";
        // bericht means message
        $bericht = $_POST['emailtekst'];
        echo "<b>Bericht: </b>".$bericht."<br />";
        echo "<hr />";
        
        if($bericht != "" && strlen($bericht) > 25 && $titel != "")
        {
            $swift =& new Swift(new Swift_Connection_SMTP("smtp.xxx.xx"));
 
            // This is what I had at first..., wich didn't work
            //$message =& new Swift_Message($titel, $bericht, "text/html");
 
            // So i thought, maybe multipart is better...(not?)
            //Create a message
            $message =& new Swift_Message($titel);
            //Add some "parts"
            $message->attach(new Swift_Message_Part($bericht));
            $message->attach(new Swift_Message_Part($bericht, "text/html"));
 
 
            $recipients =& new Swift_RecipientList();
            
            echo "Message sent to: ";
            echo "<br />";
            while ($row_klanten = mysql_fetch_array($res_klanten))
            {   
            $recipients->addTo($row_klanten['emailadres']);
            echo $row_klanten['emailadres']."<br />";
            }
         
            $swift->batchSend($message, $recipients, "me@somedomain.nl");
            
            echo "<br /><br />Message is sent.";
            
            echo "<br /><br /><br />";
            echo "Failed recipients:<br />";
            echo implode(" ,", $swift->log->getFailedRecipients());
        }
        else
        {
            echo 'No title/message or message is to short<br /><br />
            <a href="index.php">Back</a>';
            
        }
?>
 
Anyone any ideas?

Re: Why is my mail not sent?

Posted: Wed Jan 28, 2009 5:08 am
by Chris Corbyn
Could you please be a little more specific? Does your code produce any errors?

Re: Why is my mail not sent?

Posted: Wed Jan 28, 2009 5:22 am
by meddiecap
It gives no errors at all. But I think that hotmail is not letting the email through its spamfilter.

Right now, I get the emailadresses from a database, and in the script I posted it sends an email to a hotmail account.

Re: Why is my mail not sent?

Posted: Wed Jan 28, 2009 6:30 am
by Jackp29
works for me

Re: Why is my mail not sent?

Posted: Wed Jan 28, 2009 10:25 pm
by Chris Corbyn
Issues delivering to Hotmail are usually related to misconfigurations with the SMTP server. You may also be blacklisted.

Check this page for more info: http://swiftmailer.org/wikidocs/v3/tips_spam

Re: Why is my mail not sent?

Posted: Fri Jan 30, 2009 3:37 am
by meddiecap
I just checked for blacklisting and i'm OK.

I did a SMTP Diagnostics on mxtoolbox.com and got this message: "Reverse DNS FAILED"
But on http://www.computerknacks.com/tools/revdnslookup.php I was able to reverse it.

I don't know if that is the problem, because I used to be able to send mails, but not anymore. Is there a way to force a error message of some kind that can tell why my mails are not being received?

EDIT:
I seem to have solved it.

I did a MX Lookup (domain: kids-profi-portrait.com) and got 2 results.

In my mail account (from the company I work for) I use right now the mail server is SMTP.xxx.nl (not one of the results I got from the MX Lookup) and I can send and receive mails. Since I want to batchmail from this domain I used the same adress. Seemed obvious to me. But with no results, meaning, no email were received.

So, I decided to try the second result I got, and that works. Still, I wonder why I can't use the mail server I use at work.