コード例 #1
0
ファイル: smtp-relay.php プロジェクト: jasarjasu786/duitasuo
   - send mail relay (using Gmail MTA) with authentication via SSL conection (TLS encryption)
*/
// manage errors
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 (Gmail mail address)
$t = '*****@*****.**';
// to mail address
$p = 'password';
// Gmail password
// 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.';
// connect to MTA server (relay) 'smtp.gmail.com' via SSL (TLS encryption) with authentication using port '465' and timeout '10' secounds
// make sure you have OpenSSL module (extension) enable on your php configuration
$c = SMTP::connect('smtp.gmail.com', 465, $f, $p, 'tls', 10) or die(print_r($_RESULT));
// send mail relay
$s = SMTP::send($c, array($t), $m, $f);
// print result
if ($s) {
    echo 'Sent !';
} else {
    print_r($_RESULT);
}
// disconnect
SMTP::disconnect($c);
コード例 #2
0
ファイル: mime-smtp.php プロジェクト: jasarjasu786/duitasuo
// 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);
コード例 #3
0
ファイル: utils.php プロジェクト: byyeong/dc2016
function send_mail($mailto, $subject, $content, $sender_name = null, $sender_address = null)
{
    //        $subject=iconv("UTF-8", "EUC-KR", $subject);
    //        $content=iconv("UTF-8", "EUC-KR", $content);
    if (!$sender_name) {
        $settings = new Settings();
        $sender_name = $settings->default_mail_sender_name;
        //$settings->default_mail_sender_address;
    }
    //return mailer ($from, $fname, $to, $cc, $bcc, $subject, $content, $file, $type, $charset, $textencode)
    $smtp_server = "uwa64-001.cafe24.com";
    $smtp_user = "******";
    $smtp_passwd = "ok1234";
    $sender_address = "*****@*****.**";
    $boundary = "___==MultiPart_" . strtoupper(md5(uniqid(rand()))) . "==___";
    $smtp_server = "smtp.gmail.com";
    $smtp_user = "******";
    $smtp_passwd = "ok123456";
    $sender_address = "*****@*****.**";
    $smtp_sock = fsockopen($smtp_server, 25);
    /*
    fputs($smtp_sock, "HELO $smtp_server\r\n");
    fputs($smtp_sock, "VRFY $smtp_user\r\n");
    fputs($smtp_sock, "MAIL FROM:$sender_address\r\n");
    fputs($smtp_sock, "RCPT TO:$mailto\r\n");
    fputs($smtp_sock, "DATA\r\n");
    fputs($smtp_sock, "From: $sender_name<$sender_address>\r\n");
    fputs($smtp_sock, "To: $mailto\r\n");
    fputs($smtp_sock, "X-Mailer: miplus\r\n");
    fputs($smtp_sock, "Content-Type: text/html;");
    fputs($smtp_sock, "charset=UTF-8\r\n");
    fputs($smtp_sock, "MIME-Version: 1.0\r\n");
    fputs($smtp_sock, "Subject: $subject\r\n\r\n");
    fputs($smtp_sock, $content);
    fputs($smtp_sock, "\r\n\r\n.\r\nQUIT\r\n");
    */
    //include_once ("../../app/XPM/smtp.php");
    require_once "../../app/XPM/SMTP.php";
    $f = "*****@*****.**";
    $t = $mailto;
    $p = "trail1";
    $c = $content;
    $m = 'From: ' . $f . "\r\n" . 'To: ' . $t . "\r\n" . 'Subject: ' . $subject . "\r\n" . 'Content-Type: text/html' . "\r\n\r\n" . $content;
    // connect to MTA server (relay) 'smtp.gmail.com' via SSL (TLS encryption) with authentication using port '465' and timeout '10' secounds
    // make sure you have OpenSSL module (extension) enable on your php configuration
    $c = SMTP::connect('smtp.gmail.com', 465, $f, $p, 'tls', 10) or die(print_r($_RESULT));
    // send mail relay
    $s = SMTP::send($c, array($t), $m, $f);
    /*
    // print result
    if ($s) echo 'Sent !';
    else print_r($_RESULT);
    */
    // disconnect
    SMTP::disconnect($c);
}