예제 #1
0
//permite modo debug para ver mensajes de las cosas que van ocurriendo
    $mail->SMTPDebug  = 2;
//Debo de hacer autenticación SMTP
    $mail->SMTPAuth = true;
     $mail->SMTPSecure  = "ssl";
//indico el servidor de Gmail para SMTP
    $mail->Host= "smtp.gmail.com";
//indico el puerto que usa Gmail
    $mail->Port = 465;
//indico un usuario / clave de un usuario de gmail
    $mail->Username = "******";
    $mail->Password = "******";
    $mail->SetFrom('*****@*****.**', 'Julian ramirez');
    $mail->AddReplyTo("*****@*****.**","Julian ramirez");
    $mail->Subject = "Envío de email usando SMTP de Gmail";
    $mail->MsgHTML("Hola que tal, esto es el cuerpo del mensaje!");
//indico destinatario
    $address = "*****@*****.**";
    $mail->AddAddress($address, "Nombre completo");
    if(! $mail->Send()) {
        echo "Error al enviar: " .  $mail->ErrorInfo;
    } else {
        echo "Mensaje enviado!";
    }
 */
예제 #2
0
파일: Tools.php 프로젝트: djspys1/baoku
 public static function sendMail($sender, $senderPass, $toaddress, $subject, $content, $u, $attachs = null)
 {
     $mail = new JPhpMailer();
     $mail->SMTPDebug = 1;
     $mail->IsSMTP();
     $mail->Host = 'Smtpcom.263xmail.com';
     $mail->SMTPAuth = true;
     $mail->CharSet = "UTF-8";
     // 设置字符集编码
     $mail->Username = $sender;
     $mail->Password = $senderPass;
     $mail->AddAddress($toaddress, '=?UTF-8?B?' . '?=');
     // [{"url":"\/uploads\/email\/files\/1427626820-fb57060ef2463c124b894351630a4840.gif","type":"gif","name":"%}_BE}A14T2D@HBIG6}IRF4"},{"url":"\/uploads\/email\/files\/1427626820-fb57060ef2463c124b894351630a4840.gif1427626820-195715f9d4dd77b06beab61a8500b2c9.gif","type":"gif","name":"%1@X07Y86M0I25B4F9]04$B"},{"url":"\/uploads\/email\/files\/1427626820-fb57060ef2463c124b894351630a4840.gif1427626820-195715f9d4dd77b06beab61a8500b2c9.gif1427626820-fe15e4b517b0475e280cf60ea11b5bd8.gif","type":"gif","name":"%5K@8]W2XCU@{_)[M6]H{DB"}]
     if ($attachs) {
         $attachs = json_decode($attachs);
         foreach ($attachs as $attach) {
             $mail->AddAttachment(Yii::getPathOfAlias('webroot') . $attach->url, $attach->name . '.' . $attach->type);
         }
     }
     $mail->IsHTML(true);
     // send as HTML
     $mail->SetFrom($sender, '=?UTF-8?B?' . base64_encode($u->username) . '?=');
     $mail->Subject = '=?UTF-8?B?' . base64_encode($subject) . '?=';
     $mail->AltBody = 'Please switch to HTML mode to view the email';
     $content = self::embed_images($mail, $content);
     $mail->MsgHTML($content);
     $mail->Send();
 }