Xataface Email Module
0.3.2
Email/Mailmerge Module for Xataface
Main Page
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Pages
lib
XPM
EXAMPLES
mail-relay.php
Go to the documentation of this file.
1
<?php
2
3
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
4
* *
5
* XPertMailer is a PHP Mail Class that can send and read messages in MIME format. *
6
* This file is part of the XPertMailer package (http://xpertmailer.sourceforge.net/) *
7
* Copyright (C) 2007 Tanase Laurentiu Iulian *
8
* *
9
* This library is free software; you can redistribute it and/or modify it under the *
10
* terms of the GNU Lesser General Public License as published by the Free Software *
11
* Foundation; either version 2.1 of the License, or (at your option) any later version. *
12
* *
13
* This library is distributed in the hope that it will be useful, but WITHOUT ANY *
14
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A *
15
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. *
16
* *
17
* You should have received a copy of the GNU Lesser General Public License along with *
18
* this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, *
19
* Fifth Floor, Boston, MA 02110-1301, USA *
20
* *
21
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
22
23
/* Purpose:
24
- set HTML message
25
- send mail relay using Gmail MTA via SSL (TLS encryption) and authentication
26
- print result
27
*/
28
29
// manage errors
30
error_reporting(E_ALL);
// php errors
31
define(
'DISPLAY_XPM4_ERRORS'
,
true
);
// display XPM4 errors
32
33
// path to 'MAIL.php' file from XPM4 package
34
require_once
'../MAIL.php'
;
35
36
// initialize MAIL class
37
$m
=
new
MAIL;
38
// set from address
39
$m
->From(
'username@gmail.com'
);
40
// add to address
41
$m
->AddTo(
'client@destination.net'
);
42
// set subject
43
$m
->Subject(
'Hello World!'
);
44
// set HTML message
45
$m
->Html(
'<b>HTML</b> <u>message</u>.'
);
46
47
// connect to MTA server 'smtp.gmail.com' port '465' via SSL ('tls' encryption) with authentication: 'username@gmail.com'/'password'
48
// set the connection timeout to 10 seconds, the name of your host 'localhost' and the authentication method to 'plain'
49
// make sure you have OpenSSL module (extension) enable on your php configuration
50
$c
=
$m
->Connect(
'smtp.gmail.com'
, 465,
'username@gmail.com'
,
'password'
,
'tls'
, 10,
'localhost'
, null,
'plain'
) or die(print_r(
$m
->Result));
51
52
// send mail relay using the '$c' resource connection
53
echo
$m
->Send(
$c
) ?
'Mail sent !'
:
'Error !'
;
54
55
// disconnect from server
56
$m
->Disconnect();
57
58
// optional for debugging ----------------
59
echo
'<br /><pre>'
;
60
// print History
61
print_r(
$m
->History);
62
// calculate time
63
list($tm1, $ar1) = each(
$m
->History[0]);
64
list($tm2, $ar2) = each(
$m
->History[count(
$m
->History)-1]);
65
echo
'The process took: '
.(floatval($tm2)-floatval($tm1)).
' seconds.</pre>'
;
66
67
?>
Generated on Tue Mar 12 2013 11:27:42 for Xataface Email Module by
1.8.1.2