aboutsummaryrefslogtreecommitdiff
path: root/v_windows/v/old/examples/smtp/mail.v
diff options
context:
space:
mode:
authorIndrajith K L2022-12-03 17:00:20 +0530
committerIndrajith K L2022-12-03 17:00:20 +0530
commitf5c4671bfbad96bf346bd7e9a21fc4317b4959df (patch)
tree2764fc62da58f2ba8da7ed341643fc359873142f /v_windows/v/old/examples/smtp/mail.v
downloadcli-tools-windows-master.tar.gz
cli-tools-windows-master.tar.bz2
cli-tools-windows-master.zip
Adds most of the toolsHEADmaster
Diffstat (limited to 'v_windows/v/old/examples/smtp/mail.v')
-rw-r--r--v_windows/v/old/examples/smtp/mail.v36
1 files changed, 36 insertions, 0 deletions
diff --git a/v_windows/v/old/examples/smtp/mail.v b/v_windows/v/old/examples/smtp/mail.v
new file mode 100644
index 0000000..c26be33
--- /dev/null
+++ b/v_windows/v/old/examples/smtp/mail.v
@@ -0,0 +1,36 @@
+// Creator: nedimf (07/2020)
+import os
+import net.smtp
+
+fn main() {
+ println('Hi, this is sample of how to send email trough net.smtp library in V, which is really easy using the net.smtp module.')
+ println('We are going to create a simple email client, that takes some arguments. and then sends email with an HTML body.')
+ println('To fully test email sending, I suggest using the mailtrap.io service, which is free and acts like a really nice mail server sandbox.')
+ println('')
+ println('V Email client')
+ println('')
+ mailserver := os.input('Mail server: ')
+ mailport := os.input('Mail server port: ').int()
+ println('Login')
+ username := os.input('Username: ')
+ password := os.input('Password: ')
+ from := os.input('From: ')
+ to := os.input('To: ')
+ subject := os.input('Subject: ')
+ body := os.input('Body: ')
+ client_cfg := smtp.Client{
+ server: mailserver
+ from: from
+ port: mailport
+ username: username
+ password: password
+ }
+ send_cfg := smtp.Mail{
+ to: to
+ subject: subject
+ body_type: .html
+ body: body
+ }
+ mut client := smtp.new_client(client_cfg) or { panic('Error configuring smtp') }
+ client.send(send_cfg) or { panic('Error resolving email address') }
+}