Mail sending problem

public function mailsend($name, $contact_no, $email,$website,$content,$subject,$address ) 


    $message        = new YiiMailMessage;

    $message->view  = 'viewfilenm';

    $message->setBody(array(), 'text/html');

    $body           = $message->message->getBody();

    /******  preg_replace :Perform a regular expression search and replace ******/

    $body           = preg_replace('/\[FNAME]/',$name,$body); 

    $body           = preg_replace('/\[CONTENT]/',$content,$body);

    $find           = array("[CONTACT_NO]"=>$contact_no,"[FNAME]"=>$name,"[EMAIL]"=>$email,"[ADDRESS]"=>$address);

    /****** strtr :Translate characters or replace substrings ******/

    $newstr         = strtr($content, $find);

    $body           = str_replace($content,$newstr,$body);

    $body           = preg_replace('/\[CONTACT_NO]/',$contact_no,$body);

    $body           = preg_replace('/\[EMAIL]/',$email,$body);

    $body           = preg_replace('/\[SUBJECT]/',$subject,$body);

    $body           = preg_replace('/\[WEBSITE]/',$website,$body);

    $message->message->setBody($body, 'text/html');

    $message->subject = $subject;


    $message->from   = ('');



in $message->addTo() if i pass my gmail id then in gmail i got the mail. but if i pass my yahoo or other id in $message->addTo() then i dnt get the mail and no error also display. What’s the problem in my code…

Thanks in advance :)

What type of hosting are you on? If it’s shared, it’s likely some e-mail providers are blocking your message because of previous spam attempts from your IP range. There is not much you can do about this, apart from use a service like to deliver your mail for you. The fact your GMail messages are getting delivered shows that your mail server is responding.

Try various different GMail addresses (if you have them), and open some inboxes on and test from there.

ok Thank You!! :rolleyes: