-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
41 lines (33 loc) · 1.03 KB
/
index.php
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
33
34
35
36
37
38
39
40
41
<?php
// Using Swift Mailer
// Load the required vendor libraries
require_once 'vendor/autoload.php';
// Create the Transport
if ($_SERVER['SERVER_NAME'] == 'mailtrap') {
// Local SMTP mailtrap
$transport = (new Swift_SmtpTransport('smtp.mailtrap.io', 465))
->setUsername('772fbdfbf02416')
->setPassword('a22403c46020d8');
} else {
// Production SMTP client - Unix/Linux servers only
$transport = new Swift_SendmailTransport();
}
// Create the Mailer using your created Transport
$mailer = new Swift_Mailer($transport);
// Create a message
$message = (new Swift_Message('Mailtrap test'))
->setFrom(['[email protected]' => 'Bertrand C'])
->setTo(['[email protected]', '[email protected]' => 'Demo dot Org'])
->setBody('Salut les gens !');
// Send the message
$result = $mailer->send($message);
var_dump($result);
/*
// Wamp version
$mail = mail('[email protected]', 'Salut', 'Salut les gens !', 'From: [email protected]');
if ($mail) {
echo 'Merci :D';
} else {
echo 'Erreur :(';
}
*/