Ejemplo n.º 1
0
/* checks that the email entered is valid, things go real bad if the email is incorrect */
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
    echo $email . " is an invalid email format";
    die;
}
require 'phpmailer/PHPMailerAutoload.php';
$mail = new PHPmailer();
$mail->IsSMTP();
$mail->SMTPDebug = 2;
$mail->Debugoutput = 'html';
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->SMTPSecure = "tls";
$mail->Port = 587;
$mail->Username = "******";
// GMAIL username
$mail->Password = "******";
// GMAIL username
$email_to = "*****@*****.**";
$name_to = "Mikoto";
$mail->AddAddress($email_to, $name_to);
$mail->SetFrom($email, $fullname);
$mail->Subject = "dA Art Website: " . $subject;
$mail->Body = $message;
try {
    $mail->Send();
} catch (Exception $e) {
    echo "<h1>Not working :(</h1>";
    die;
}
header('Location: contact.html');
Ejemplo n.º 2
0
function mailstream_send($a, $message_id, $item, $user)
{
    if (!$item['visible']) {
        return;
    }
    if (!$message_id) {
        return;
    }
    require_once dirname(__FILE__) . '/class.phpmailer.php';
    require_once 'include/bbcode.php';
    $attachments = array();
    mailstream_do_images($a, $item, $attachments);
    $frommail = get_config('mailstream', 'frommail');
    if ($frommail == "") {
        $frommail = '*****@*****.**';
    }
    $address = get_pconfig($item['uid'], 'mailstream', 'address');
    if (!$address) {
        $address = $user['email'];
    }
    $mail = new PHPmailer();
    try {
        $mail->XMailer = 'Friendica Mailstream Plugin';
        $mail->SetFrom($frommail, mailstream_sender($item));
        $mail->AddAddress($address, $user['username']);
        $mail->MessageID = $message_id;
        $mail->Subject = mailstream_subject($item);
        if ($item['thr-parent'] != $item['uri']) {
            $mail->addCustomHeader('In-Reply-To: ' . mailstream_generate_id($a, $item['thr-parent']));
        }
        $mail->addCustomHeader('X-Friendica-Mailstream-URI: ' . $item['uri']);
        $mail->addCustomHeader('X-Friendica-Mailstream-Plink: ' . $item['plink']);
        $encoding = 'base64';
        foreach ($attachments as $url => $image) {
            $mail->AddStringEmbeddedImage($image['data'], $image['guid'], $image['filename'], $encoding, $image['type']);
        }
        $mail->IsHTML(true);
        $mail->CharSet = 'utf-8';
        $template = get_markup_template('mail.tpl', 'addon/mailstream/');
        $item['body'] = bbcode($item['body']);
        $item['url'] = $a->get_baseurl() . '/display/' . $user['nickname'] . '/' . $item['id'];
        $mail->Body = replace_macros($template, array('$upstream' => t('Upstream'), '$local' => t('Local'), '$item' => $item));
        mailstream_html_wrap($mail->Body);
        if (!$mail->Send()) {
            throw new Exception($mail->ErrorInfo);
        }
        logger('mailstream_send sent message ' . $mail->MessageID . ' ' . $mail->Subject, LOGGER_DEBUG);
    } catch (phpmailerException $e) {
        logger('mailstream_send PHPMailer exception sending message ' . $message_id . ': ' . $e->errorMessage(), LOGGER_NORMAL);
    } catch (Exception $e) {
        logger('mailstream_send exception sending message ' . $message_id . ': ' . $e->getMessage(), LOGGER_NORMAL);
    }
    // In case of failure, still set the item to completed.  Otherwise
    // we'll just try to send it over and over again and it'll fail
    // every time.
    q('UPDATE `mailstream_item` SET `completed` = now() WHERE `message-id` = "%s"', dbesc($message_id));
}
Ejemplo n.º 3
0
 public function MailTransfer($mailSendAddress, $MailName, $code)
 {
     $mail = new PHPmailer();
     $mail->IsSMTP();
     $mail->SMTPAuth = true;
     $mail->Host = "smtp.gmail.com";
     $mail->Port = 465;
     $mail->Username = "******";
     $mail->Password = "******";
     $mail->SMTPSecure = 'ssl';
     $mail->SetFrom('*****@*****.**', 'Mortuza');
     $mail->Subject = "Confirmation message  from New Main Zone ";
     $mail->AltBody = "Any message.";
     $mail->MsgHTML($code);
     $address = $mailSendAddress;
     $mail->AddAddress($address, $MailName);
     if (!$mail->Send()) {
         echo $mail->ErrorInfo;
         return 0;
     } else {
         return 1;
     }
 }