utiliza phpmailer y te evitas esos problemas un ejemplo de php mailer para google seria este:
Código PHP:
Ver originalrequire_once 'class.phpmailer.php';
{
private $puerto;
private $userName;
private $password;
private $host;
private $mail;
public function __construct(){
$this->puerto = 465;
$this->password = "*****";
$this->host = "ssl://smtp.gmail.com";
$this->mail = new PHPMailer
(); }
public function SenMail($userMail,$body,$FromName = '',$Subject = '')
{
$this->mail -> From = $userMail; $this->mail -> FromName = $FromName; $this->mail -> AddAddress ($userMail); $this->mail -> Subject = $Subject; $this->mail -> Body = $body; $this->mail -> IsHTML (true);
$this->mail->IsSMTP();
$this->mail->Host = $this->host;
$this->mail->Port = $this->puerto;
$this->mail->SMTPAuth = true;
$this->mail->Username = $this->UserName;
$mail->Password = $this->password;
//$this->mail->AddAttachment("images/foto.jpg", "foto.jpg");
if(!$this->mail->Send()){
throw new Exception('Error: ' . $this->mail->ErrorInfo);
return false;
}else
return true;
}
public function __destruct(){
}
}