コード例 #1
0
ファイル: mime-smtp.php プロジェクト: jasarjasu786/duitasuo
$to = '*****@*****.**';
// to mail address
$subj = 'Hello World!';
// mail subject
$text = 'Text version of message.';
// text/plain version of message
$html = '<b>HTML</b> version of <u>message</u>.';
// text/html version of message
// CONFIGURATION ------------------
// set text/plain version of message
$msg1 = MIME::message($text, 'text/plain');
// set text/html version of message
$msg2 = MIME::message($html, 'text/html');
// compose message in MIME format
$mess = MIME::compose($msg1, $msg2);
// standard mail message RFC2822
$body = 'From: ' . $from . "\r\n" . 'To: ' . $to . "\r\n" . 'Subject: ' . $subj . "\r\n" . $mess['header'] . "\r\n\r\n" . $mess['content'];
// get client hostname
$expl = explode('@', $to);
// connect to SMTP server (direct) from MX hosts list
$conn = SMTP::mxconnect($expl[1]) or die(print_r($_RESULT));
// send mail
$sent = SMTP::send($conn, array($to), $body, $from);
// print result
if ($sent) {
    echo 'Sent !';
} else {
    print_r($_RESULT);
}
// disconnect from SMTP server
SMTP::disconnect($conn);
コード例 #2
0
ファイル: smtp-client.php プロジェクト: jasarjasu786/duitasuo
error_reporting(E_ALL);
// php errors
define('DISPLAY_XPM4_ERRORS', true);
// display XPM4 errors
// path to 'SMTP.php' file from XPM4 package
require_once '../SMTP.php';
$f = '*****@*****.**';
// from mail address
$t = '*****@*****.**';
// to mail address
$p = '*****@*****.**';
// return-path
// standard mail message RFC2822
$m = 'From: ' . $f . "\r\n" . 'To: ' . $t . "\r\n" . 'Subject: test' . "\r\n" . 'Content-Type: text/plain' . "\r\n\r\n" . 'Text message.';
// get client hostname
$h = explode('@', $t);
// optional, connect to the internet using IP '127.0.0.1'
$r = stream_context_create(array('socket' => array('bindto' => '127.0.0.1:0')));
// connect to SMTP server (direct) from MX hosts list to port '25' and timeout '10' secounds
// optional, set hostname 'localdomain.net' for EHLO/HELO SMTP dialog
$c = SMTP::mxconnect($h[1], 25, 10, 'localdomain.net', $r) or die(print_r($_RESULT));
// send mail and set return-path '$p' in 'MAIL FROM' SMTP dialog
$s = SMTP::send($c, array($t), $m, $p);
// print result
if ($s) {
    echo 'Sent !';
} else {
    print_r($_RESULT);
}
// disconnect
SMTP::disconnect($c);