Ruby

Ruby vous permet d'envoyer simplement des emails en SMTP grâce à une librairie : mail

Pour installer mail, nous allons utiliser gem.

1
gem install mail

Vous pouvez maintenant utiliser la librairie dans votre application. Voici un exemple de code que vous pouvez adapter

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*
  * File Name : send.rb
  * Task : send email through Tipimail
 */
 
require 'mail'
 
Mail.defaults do
    delivery_method :smtp, {
        :port      => 587,
        :address   => "smtp.tipimail.com",
        :user_name => "username",
        :password  => "password"
    }
end
 
mail = Mail.deliver do
    from    'contact@mail.tipimail.com'
    to      'to@mail.tipimail.com'
    subject 'sujet de votre email'
 
    text_part do
        body 'Message au format texte'
    end
 
    html_part do
        content_type 'text/html; charset=UTF-8'
        body 'Message au format html'
    end
end

Il ne vous reste plus qu'à appeler votre script

1
ruby send.rb