-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathemail_test.php
More file actions
50 lines (44 loc) · 1.9 KB
/
Copy pathemail_test.php
File metadata and controls
50 lines (44 loc) · 1.9 KB
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
<?php
include "includes/classes.inc.php";
require_once './includes/lib/swift_required.php';
$transport = Swift_MailTransport::newInstance();
if ( $settings->get_value(kSettingEmailType)==kEmailTypeSendmail ){
// Sendmail
$transport = Swift_SendmailTransport::newInstance('/usr/sbin/sendmail -bs');
}
else if ( $settings->get_value(kSettingEmailType)==kEmailTypeSMTP ){
// Create the Transport
$transport = Swift_SmtpTransport::newInstance($settings->get_value(kSettingSMTPServer), $settings->get_value(kSettingSMTPPort))
->setUsername($settings->get_value(kSettingSMTPUser))
->setPassword($settings->get_value(kSettingSMTPPassword));
if ( $settings->get_value(kSettingSMTPEncryptType)==kSettingSMTPEncryptTypeSSL )
$transport->setEncryption('ssl');
else if ( $settings->get_value(kSettingSMTPEncryptType)==kSettingSMTPEncryptTypeTLS )
$transport->setEncryption('tls');
}
$statement = "select * from team where team_id = '".kAdminUser."'";
$row = mysql_fetch_array(mysql_query($statement));
$fromaddress = $row['team_email'];
// Create the Mailer using your created Transport
$mailer = Swift_Mailer::newInstance($transport);
// Create the message
$messagetosend = Swift_Message::newInstance()
// Give the message a subject
->setSubject('Test Email')
// Set the From address with an associative array
->setFrom(array($fromaddress => 'FOF Draft Admin'))
// Set the To addresses with an associative array
->setTo(array($fromaddress))
// Give it a body
->setBody('This is a test email message.');
// Send the message
try{
$emailresult = $mailer->send($messagetosend);
} catch(Exception $e){
$_SESSION['message'] = "Error sending email: ".$e->getMessage();
}
if (!$_SESSION['message'])
$_SESSION['message'] = "Test email sent. Response: ".$result;
// Return to the main page
header("Location: draft_options.php");
?>