📜  发送电子邮件 php smtp 托管程序 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:17.051000             🧑  作者: Mango

代码示例2
Hello ";
$mail = new PHPMailer(true);
try {
    //Server settings
    $mail->isSMTP();                                          
    $mail->Host       = 'smtp.titan.email'; 
    $mail->SMTPAuth   = true;                                 
    $mail->Username   = 'contact@domain.com';               
    $mail->Password   = 'password';                           
    $mail->SMTPSecure = 'ssl';                                  
    $mail->Port       = 465;                                  

    //Recipients
    $mail->setFrom('contact@domain.com', 'domain Team');
    $mail->addAddress('receiver1@gmail.com', 'Joe User');    
    $mail->addAddress('receiver2@gmail.com', 'Joe User');    
    // Attachments
    // Content
    $mail->isHTML(true);                                 
    $mail->Subject = 'Here is the subject';
    $mail->Body    = $html;
    $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
    $mail->send();
    echo true;

} catch (Exception $e) {
    echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}