/
smtpwork.php
63 lines (53 loc) · 2.96 KB
/
smtpwork.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
<?php
/*
* test_smtp.php
*
* @(#) $Header: /home/mlemos/cvsroot/smtp/test_smtp.php,v 1.18 2009/04/11 22:23:24 mlemos Exp $
*
*/
require("smtp.php");
require("sasl.php");
$sender="Website@school.sch.uk"; /* Change this to your address like "me@mydomain.com"; */
$sender_line=__LINE__;
if(strlen($sender)==0)
die("Please set the messages sender address in line ".$sender_line." of the script ".basename(__FILE__)."\n");
if(strlen($to)==0)
die("Please set the messages recipient address in line ".$recipient_line." of the script ".basename(__FILE__)."\n ".vardump($recipient));
$smtp=new smtp_class;
$smtp->host_name="smtp-relay.gmail.com"; //IP address /* Change this variable to the address of the SMTP server to relay, like "smtp.myisp.com" */
$smtp->host_port=587; /* Change this variable to the port of the SMTP server to use, like 465 */
$smtp->ssl=0; /* Change this variable if the SMTP server requires an secure connection using SSL */
$smtp->start_tls=1; /* Change this variable if the SMTP server requires security by starting TLS during the connection */
$smtp->localhost="www"; /* Your computer address */
$smtp->direct_delivery=0; /* Set to 1 to deliver directly to the recepient SMTP server */
$smtp->timeout=10; /* Set to the number of seconds wait for a successful connection to the SMTP server */
$smtp->data_timeout=0; /* Set to the number seconds wait for sending or retrieving data from the SMTP server.
Set to 0 to use the same defined in the timeout variable */
$smtp->debug=1; /* Set to 1 to output the communication with the SMTP server */
$smtp->html_debug=1; /* Set to 1 to format the debug output as HTML */
$smtp->pop3_auth_host=""; /* Set to the POP3 authentication host if your SMTP server requires prior POP3 authentication */
$smtp->user=""; /* Set to the user name if the server requires authetication */
$smtp->realm=""; /* Set to the authetication realm, usually the authentication user e-mail domain */
$smtp->password=""; /* Set to the authetication password */
$smtp->workstation="www"; /* Workstation name for NTLM authentication */
$smtp->authentication_mechanism=""; /* Specify a SASL authentication method like LOGIN, PLAIN, CRAM-MD5, NTLM, etc..
Leave it empty to make the class negotiate if necessary */
$recipients = explode(',',$to);
foreach($recipients as $recipient){
if($smtp->SendMessage(
$sender,
array(
$recipient
),
array(
"From: $sender",
"To: $to",
"Subject: $subject",
"Date: ".strftime("%a, %d %b %Y %H:%M:%S %Z")
),
"$message"))
echo "Message sent. \n";
else
echo "Cound not send message.\nError: ".$smtp->error."\n";
}
?>