Hỏi về code gửi mail bằng javascript

Chào cả nhà, mình có bài tập gửi mail viết bằng javascript nhưng chưa biết viết như thế nào cả, không biết có ai giúp mình được không ạ. Cảm ơn nhiểu
 
  • Chủ đề
    sgsđ
  • VSupport

    Ngây thơ trong tối
    Bạn tham khảo bài này nhé. PHP thì dễ chứ javascript thì :))
    Mã:
    https://medium.com/@mariusc23/send-an-email-using-only-javascript-b53319616782#.udmh12n2x
     
    Trên một số diễn đàn bằng php mình thấy có code sau
    <?php
    include "class.phpmailer.php";
    include "class.smtp.php";
    function send_gmail($from_email, $from_email_pass, $to_email, $to_name, $subject, $content, $from_name=''){
    $mail = new PHPMailer();
    $mail->IsSMTP(); // set mailer to use SMTP
    $mail->Host = "smtp.gmail.com"; // specify main and backup server
    $mail->Port = 465; // set the port to use
    $mail->SMTPAuth = true; // turn on SMTP authentication
    $mail->SMTPSecure = 'ssl';
    $mail->Username = $from_email; // your SMTP username or your gmail username
    $mail->Password = $from_email_pass; // your SMTP password or your gmail password
    $mail->From = $from_email;
    $mail->FromName = $from_name; // Name to indicate where the email came from when the recepient received
    $mail->AddAddress($to_email,$to_name);
    $mail->AddReplyTo($from_email,$from_name);
    $mail->WordWrap = 50; // set word wrap
    $mail->IsHTML(true); // send as HTML
    $mail->Subject = $subject;
    $mail->Body = $content; //HTML Body
    return $mail->Send();
    }
    ?>
    Nhưng chuyển từ cái này sang javascript thì mình chưa thấy, có một vài code nhưng lại chẳng thấy mấy thuộc tính này ở đâu
    $mail->Host = "smtp.gmail.com"; // specify main and backup server
    $mail->Port = 465; // set the port to use
    $mail->SMTPAuth = true; // turn on SMTP authentication
    $mail->SMTPSecure = 'ssl';
    mà không có cái này sao gửi được.
    Ai biết hổ trợ với
    Cảm ơn cả nhà rất nhiều
     

    VSupport

    Ngây thơ trong tối
    Trên một số diễn đàn bằng php mình thấy có code sau
    <?php
    include "class.phpmailer.php";
    include "class.smtp.php";
    function send_gmail($from_email, $from_email_pass, $to_email, $to_name, $subject, $content, $from_name=''){
    $mail = new PHPMailer();
    $mail->IsSMTP(); // set mailer to use SMTP
    $mail->Host = "smtp.gmail.com"; // specify main and backup server
    $mail->Port = 465; // set the port to use
    $mail->SMTPAuth = true; // turn on SMTP authentication
    $mail->SMTPSecure = 'ssl';
    $mail->Username = $from_email; // your SMTP username or your gmail username
    $mail->Password = $from_email_pass; // your SMTP password or your gmail password
    $mail->From = $from_email;
    $mail->FromName = $from_name; // Name to indicate where the email came from when the recepient received
    $mail->AddAddress($to_email,$to_name);
    $mail->AddReplyTo($from_email,$from_name);
    $mail->WordWrap = 50; // set word wrap
    $mail->IsHTML(true); // send as HTML
    $mail->Subject = $subject;
    $mail->Body = $content; //HTML Body
    return $mail->Send();
    }
    ?>
    Nhưng chuyển từ cái này sang javascript thì mình chưa thấy, có một vài code nhưng lại chẳng thấy mấy thuộc tính này ở đâu
    $mail->Host = "smtp.gmail.com"; // specify main and backup server
    $mail->Port = 465; // set the port to use
    $mail->SMTPAuth = true; // turn on SMTP authentication
    $mail->SMTPSecure = 'ssl';
    mà không có cái này sao gửi được.
    Ai biết hổ trợ với
    Cảm ơn cả nhà rất nhiều
    Cái này gửi bằng SMTP của Gmail đó bạn. Còn nếu muốn code php không thì Code PHP gửi Email đơn giản test hàm mail()

    Gửi bằng javasript thì dùng ajax thôi như link kia kìa
     
    Nếu dùng ajax thì mình không thấy cổng post đâu cả, bạn giải thích hộ mình được không
     
    Top