JavaScriptでメールを送信する最も簡単な方法
8725 ワード
Ahoyがそこにsweetlings!メールを送りましょう!しかし、非常に楽しい方法で!楽しい楽しみのために、同様にTypesScriptを加えましょう!あなたがそれを知らない場合でも、心配しないでください、我々はレベル0から行く!JavaScriptのための基礎を知っている限り、ホップ!
ステップ0 :プロジェクトを開始する
フォルダを作成し、お気に入りのエディタで開きます.次に、このコマンドをプロジェクト端末に入力します
ボーナスステップ:タイプスクリプトを加えること
環境を設定して、typescriptファイルを走らせる方法で少し失われる人々のために
まあとにかく、短くて(詳しくは上記のリンクをチェックしてください)タイプスクリプトをインストールする
initの設定
(入力されたNPM I - G TypeScriptではなく、以前の正規のNPM Iというタイプのコマンドで混乱しません).
TSノードとTSノードをインストールします
ステップ1:送信メール
最初にこのコマンドで必要なパッケージをインストールします
今すぐいくつかのフレークメールを送信しましょう!アプリの中.TSファイル
八穂王!我々はちょうどいくつかのfreakingユーザーにフリークメールを送信!ああ!しかし、本当に?あなたはこのような狂ったエラーを見ている必要がありますか?
Googleがその要求をブロックしたので!それで、それを働かせるために、我々は最初にその電子メールアカウントから電子メールを送るのを許す必要があります.どうやって?Googleは“以下の安全なアプリ”と最初のリンクを開きます.
今このようなものが表示されます
トグルボタンをオンにする
今すぐもう一度メール送信者ファイルを実行してください!そして!あなただけのフレークメールを送信!甘やかす
次は何ですか.
1 .何かできるように改良されたAI bot
2 . Javascript/typescriptによる非常識なもの
VSコードデバッガによるスクリプトのデバッグ
自動化の方法
フックの順序付け
DBスキーマの自動作成
XPでAndroidアプリを作成する方法
( apk生成を含む)
何か疑いが?
コメントをドロップするか、私に連絡して無料@ @
私についてもっと知りたいですか?ここに来なさい!
SilvenLEAF.github.io
ステップ0 :プロジェクトを開始する
フォルダを作成し、お気に入りのエディタで開きます.次に、このコマンドをプロジェクト端末に入力します
npm init -y
(ダウンロードしたパッケージをすべて追跡するpackage . jsonファイルを作成します).ボーナスステップ:タイプスクリプトを加えること
環境を設定して、typescriptファイルを走らせる方法で少し失われる人々のために
まあとにかく、短くて(詳しくは上記のリンクをチェックしてください)
npm i typescript
(入力されたNPM I - G TypeScriptではなく、以前の正規のNPM Iというタイプのコマンドで混乱しません).
tsc --init
( tsconfigファイルを作成します)npm i ts-node ts-node-dev
今すぐアプリを作成しましょう.TSファイルといくつかのフレークメールを送信!ステップ1:送信メール
最初にこのコマンドで必要なパッケージをインストールします
npm i nodemailer @types/nodemailer
( NPM I Xは"NPM Installation X "のショートバージョンです)今すぐいくつかのフレークメールを送信しましょう!アプリの中.TSファイル
import nodemailer from 'nodemailer';
// let's create the transport (it's the postman/delivery-man who will send your emails)
const myTransport = nodemailer.createTransport({
service: 'Gmail',
auth: {
user: '[email protected]', // your gmail account which you'll use to send the emails
pass: 'YOUR_GMAIL_PASSWORD', // the password for your gmail account
}
});
// defining the content of the email (I mean, what will be on the email)
const mailOptions = {
from: 'SilvenLEAF<[email protected]>', // from where the email is going, you can type anything or any name here, it'll be displayed as the sender to the person who receives it
to: '[email protected],[email protected],[email protected]', // the email address(es) where you want to send the emails to. If it's more than one person/email, seperate them with a comma, like here how I seperated the 3 users with a comma
subject: 'Sending Some Freaking Email', // your email subject (optional but better to have it)
text: `Hello there my sweetling! Let's send some freaking emails!`, // your email body in plain text format (optional)
// your email body in html format (optional)
// if you want to send a customly and amazingly designed html body
// instead of a boring plain text, then use this "html" property
// instead of "text" property
html: `<h1 style="color: red;text-align:center">Hello there my sweetling!</h1>
<p style="text-align:center">Let's send some <span style="color: red">freaking</span> emails!</p>`,
}
// sending the email
myTransport.sendMail(mailOptions, (err) => {
if (err) {
console.log(`Email is failed to send!`);
console.error(err);
} else {
console.log(`Email is successfully sent!`);
}
})
余宝!我々は、ちょうど電子メール送信者ファイルを作成しました.さあ、走りましょう.次のコマンドを入力して、このファイルを実行しますts-node app.ts
(これはノードapp . jsのタイプスクリプト版です)八穂王!我々はちょうどいくつかのfreakingユーザーにフリークメールを送信!ああ!しかし、本当に?あなたはこのような狂ったエラーを見ている必要がありますか?
Googleがその要求をブロックしたので!それで、それを働かせるために、我々は最初にその電子メールアカウントから電子メールを送るのを許す必要があります.どうやって?Googleは“以下の安全なアプリ”と最初のリンクを開きます.
今このようなものが表示されます
トグルボタンをオンにする
今すぐもう一度メール送信者ファイルを実行してください!そして!あなただけのフレークメールを送信!甘やかす
次は何ですか.
1 .何かできるように改良されたAI bot
2 . Javascript/typescriptによる非常識なもの
VSコードデバッガによるスクリプトのデバッグ
自動化の方法
フックの順序付け
DBスキーマの自動作成
XPでAndroidアプリを作成する方法
( apk生成を含む)
何か疑いが?
コメントをドロップするか、私に連絡して無料@ @
私についてもっと知りたいですか?ここに来なさい!
SilvenLEAF.github.io
Reference
この問題について(JavaScriptでメールを送信する最も簡単な方法), 我々は、より多くの情報をここで見つけました https://dev.to/silvenleaf/easiest-way-to-send-emails-with-javascript-by-silvenleaf-252bテキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol