Jump to content

550 error when using mail(), invalid recipient...?


inVINCEable

Recommended Posts

I have set up the mail function correctly, and have tried SEVERAL smtp servers only to keep getting a 550 error, invalid recipient. I have read that it has something to do with the from headers, as I have tried setting up in the function itself, and using ini_set('smtpmail_from', $from_header)

 

Does anyone have any advice? Thank you.

function mailpassword(){
       
        ini_set("sendmail_from", "[email protected]");

        echo "hello";
         
        $persons_to_email = $this->Reset->findAll();
       
        foreach ($persons_to_email as $person){
           
            $email_address = $person['Reset']['email'];
            $reset_code = $person['Reset']['reset_code']; e
           
            $message = "Please visit the link below to reset your password...";
            $message .= "http://localhost/users/newpassword/$reset_code"; 
             
           
            if(mail($email_address, "Password reset to NzbNation", $message))
            {
                $id_to_delete = $person['Reset']['id'];
                $this->Reset->delete($id_to_delete);
            }
           
           
           
        }
       

       
       
   
    } 

 

 

Sorry... here it is.

function mailpassword(){
       
        ini_set("sendmail_from", "[email protected]");

        echo "hello";
         
        $persons_to_email = $this->Reset->findAll();
       
        foreach ($persons_to_email as $person){
           
            $email_address = $person['Reset']['email'];
            $reset_code = $person['Reset']['reset_code']; e <----- Whats this for?
           
            $message = "Please visit the link below to reset your password...";
            $message .= "http://localhost/users/newpassword/$reset_code"; 
             
           
            if(mail($email_address, "Password reset to NzbNation", $message))
            {
                $id_to_delete = $person['Reset']['id'];
                $this->Reset->delete($id_to_delete);
            }
           
           
           
        }
       

       
       
   
    } 

function mailpassword(){
       
        ini_set("sendmail_from", "[email protected]");

        echo "hello";
         
        $persons_to_email = $this->Reset->findAll();
       
        foreach ($persons_to_email as $person){
           
            $email_address = $person['Reset']['email'];
            $reset_code = $person['Reset']['reset_code']; e <----- Whats this for?
           
            $message = "Please visit the link below to reset your password...";
            $message .= "http://localhost/users/newpassword/$reset_code"; 
             
           
            if(mail($email_address, "Password reset to NzbNation", $message))
            {
                $id_to_delete = $person['Reset']['id'];
                $this->Reset->delete($id_to_delete);
            }
           
           
           
        }
       

       
       
   
    } 

 

 

It is added onto the URL that is sent in the message. Look at the 2nd line after that.

 

$message .= "http://localhost/users/newpassword/$reset_code";

 

 

try echoing $email_address and seeing what it says. It looks like that's where your problem lies - the recipients email address is incorrect.

 

I did and it echoed the email address properly. I have even tried several extensions, using gmail, hotmail, and netscape.

That's an interesting one. If the email address is echoing out the correct address before the function, then it should be going through, as your mail function looks to be formed properly.

 

Maybe you could take a different direction and try using a mailing class. I use phpmailer myself - its quite easy to use and works well. There is a decent tutorial on the site that explains how to use it as well.

 

Unfortunately however, this doesn't really solve your problem, rather it just works around it. I prefer to solve problems, so my reply here isn't very good.

 

 

I do have one question though - you said you are getting the 550 error. Where are you seeing this error?

I am seeing this error in the CMD window. I am running this as a CRON job. I will attempt to use a mailing class in a few hours or tomorrow hopefully. But I am very much like you and like to solve my problems as it makes me feel more at ease.  :)

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.