PHP

E-Mail versenden per SSL

Im Beispiel wird PHPMailer verwendet.

require_once('includes/class.phpmailer.php');
require_once('includes/class.smtp.php');
 
$mail = new PHPMailer(); 
$mail->IsSMTP();
$mail->Host = "smtp.mydomin.com";
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Username = "mymail@mydomain.com";
$mail->Password = "**********";
$mail->Port = "465";
$mail->SetFrom('mymail@mydomain.com', 'MyName');
$mail->AddReplyTo("mymail@mydomain.com", "MyName");
$mail->Subject    = "Mein Betreff";
$mail->AltBody    = "Mein Mail Body. Bla bla!";
$mail->MsgHTML("<h1>Main Mail Body.</h1> Bla bla!");
$address = "tomail@mydomain.com";
$mail->AddAddress($address, "MyName");
 
if(!$mail->Send()) {
   echo "Error: " . $mail->ErrorInfo;
} else {
   echo "OK";
}