-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathnomad_mimemail.test.php
91 lines (75 loc) · 2.26 KB
/
nomad_mimemail.test.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
/**
* This example, sends a Text + HTML + Embedded Image + Atachment eMail
* via Auth SMTP
*/
/**
* We need to include the class and declare it
*/
include ('nomad_mimemail.inc.php');
$mimemail = new nomad_mimemail();
/**
* Asign SMTP values need to connect
* Note: SMTP user can be a email if needs
*/
$smtp_host = "smtp.host.com"; // *Change Value*
$smtp_user = "user"; // *Change Value*
$smtp_pass = "pass"; // *Change Value*
/**
* Asign mail variables to create the mail
* Check the $html var, have a img tag with src='image.gif'
*/
$from = "[email protected]"; // *Change Value*
$to = "[email protected]"; // *Change Value*
$subject = "Nomad MIME Mail example";
$text = "This is a MIME Mail Plain Text\n\n";
$html = "<p>This is a <b>MIME</b> Mail with:</p>
<ul>
<li>Text</li>
<li>HTML</li>
<li>Embedded Image</li>
<li>Attachment</li>
</ul>
<img src='my_image.jpg' border='0'>";
/**
* Asign Atachments file path and name variables
*/
$attach_image = "test_files/image.jpg";
$attach_file = "test_files/file.gz";
/**
* Asign all the vars in the class
*/
$mimemail->set_from($from);
$mimemail->set_to($to);
$mimemail->set_subject($subject);
$mimemail->set_text($text);
$mimemail->set_html($html);
// Shortcut to declare the 5 lines above
// $mimemail->new_mail($from, $to, $subject, $text, $html);
/**
* Adding Atachments with it's file name, you can see the
* image name in the method is the same declared in the HTML text
* for the Embedded Image works
*/
$mimemail->add_attachment($attach_image, "my_image.jpg");
$mimemail->add_attachment($attach_file, "my_file.gz");
/**
* Asign the SMTP values to connect.
* If you dont need Auth SMTP you can comment the set_smtp_auth method.
* If you dont need any SMTP you can comment both lines and the mail sends via
* PHP mail function.
*/
//$mimemail->set_smtp_log(true); // If you need debug SMTP connection
$mimemail->set_smtp_host($smtp_host);
$mimemail->set_smtp_auth($smtp_user, $smtp_pass);
/**
* Send the mail
*/
if ($mimemail->send()){
echo "The MIME Mail has been sent";
}
else {
echo "An error has occurred, mail was not sent";
}
//echo "<br><br><textarea cols=80 rows=30>" . $mimemail->get_smtp_log() . "</textarea>"; // If you need debug SMTP connection
?>