2015-04-16 35 views

回答

0

您可以使用phpmailer类。 PHPMailer的是一个不错的选择

<?php 

$mail = new PHPMailer(true); 

//Send mail using gmail 
if($send_using_gmail){ 
    $mail->IsSMTP(); // telling the class to use SMTP 
    $mail->SMTPAuth = true; // enable SMTP authentication 
    $mail->SMTPSecure = "ssl"; // sets the prefix to the servier 
    $mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server 
    $mail->Port = 465; // set the SMTP port for the GMAIL server 
    $mail->Username = "[email protected]"; // GMAIL username 
    $mail->Password = "your-gmail-password"; // GMAIL password 
} 

//Typical mail data 
$mail->AddAddress($email, $name); 
$mail->SetFrom($email_from, $name_from); 
$mail->Subject = "My Subject"; 
$mail->Body = "Mail contents"; 

try{ 
    $mail->Send(); 
    echo "Success!"; 
} catch(Exception $e){ 
    //Something went bad 
    echo "Fail - " . $mail->ErrorInfo; 
} 

?> 

phpmailer class

+0

谢谢马尼什的答案,但这个有PHP梅勒的依赖,而且它正在发送的实际的邮件。我更喜欢一种只显示发送邮件时的样子。 –

相关问题