function f_SEND($t_email = '', $t_asunto = '', $t_contenido) { require_once '../modelo/phpmailer/class.phpmailer.php'; $a_email = new phpmailer(); $a_email->Mailer = "smtp"; $a_email->Host = ""; $a_email->SMTPAuth = true; $a_email->Port = '465'; $a_email->CharSet = 'utf8'; $a_email->Username = ''; $a_email->Password = ''; $a_email->From = ''; $a_email->FromName = '' . utf8_decode(''); //escribir la el contenido del correo //dirección destino $a_correo = '' . $t_email; $a_email->addAddress($a_correo); $a_email->Subject = '' . utf8_decode('' . $t_asunto); $a_email->AddEmbeddedImage('../imagenes/inen_header.png', 'logoinen', 'inen_header.png'); $a_email->IsHTML(true); $a_email->Body = "<p><img src=\"cid:logoinen\" /></p><p>" . utf8_decode('' . $t_contenido) . "</p>"; $a_email->AltBody = ' '; if ($a_email->send()) { echo "</br>Mensaje enviado correctamente.</br>"; } else { echo "<br/><strong>Información:</strong><br/>" . $a_email->ErrorInfo; } }
function send_mail($email, $date, $time) { require '../phpmailer/PHPMailerAutoload.php'; $mail = new phpmailer(); $mail->isSMTP(); $mail->Host = 'smtp.gmail.com'; $mail->SMTPAuth = true; $mail->Username = '******'; $mail->Password = '******'; $mail->SMTPSecure = 'tls'; $mail->Port = 587; $mail->setFrom('*****@*****.**', 'Mailer'); $mail->addAddress('' . $email . '', 'user'); $mail->isHTML(true); $mail->Subject = 'booking'; $mail->Body = 'This email is coming from global styling to: ' . $email . ' </br> your booking is set for ' . $date . ' at ' . $time . ' thank you for booking with us. Global Styling'; $mail->AltBody = 'This is the body in plain text for non-HTML mail clients'; if (!$mail->send()) { echo 'Message could not be sent.'; echo 'Mailer Error: ' . $mail->ErrorInfo; } else { echo 'Message has been sent to your E-Mail address'; } }
/** * Always use this function for all emails to users * * @param object $userto user object to send email to. must contain firstname,lastname,preferredname,email * @param object $userfrom user object to send email from. If null, email will come from mahara * @param string $subject email subject * @param string $messagetext text version of email * @param string $messagehtml html version of email (will send both html and text) * @param array $customheaders email headers * @throws EmailException * @throws EmailDisabledException */ function email_user($userto, $userfrom, $subject, $messagetext, $messagehtml = '', $customheaders = null) { global $IDPJUMPURL; static $mnetjumps = array(); if (!get_config('sendemail')) { // You can entirely disable Mahara from sending any e-mail via the // 'sendemail' configuration variable return true; } if (empty($userto)) { throw new InvalidArgumentException("empty user given to email_user"); } if (!($mailinfo = can_receive_email($userto))) { throw new EmailDisabledException("email for this user has been disabled"); } // If the user is a remote xmlrpc user, trawl through the email text for URLs // to our wwwroot and modify the url to direct the user's browser to login at // their home site before hitting the link on this site if (!empty($userto->mnethostwwwroot) && !empty($userto->mnethostapp)) { require_once get_config('docroot') . 'auth/xmlrpc/lib.php'; // Form the request url to hit the idp's jump.php if (isset($mnetjumps[$userto->mnethostwwwroot])) { $IDPJUMPURL = $mnetjumps[$userto->mnethostwwwroot]; } else { $mnetjumps[$userto->mnethostwwwroot] = $IDPJUMPURL = PluginAuthXmlrpc::get_jump_url_prefix($userto->mnethostwwwroot, $userto->mnethostapp); } $wwwroot = get_config('wwwroot'); $messagetext = preg_replace_callback('%(' . $wwwroot . '([\\w_:\\?=#&@/;.~-]*))%', 'localurl_to_jumpurl', $messagetext); $messagehtml = preg_replace_callback('%href=["\'`](' . $wwwroot . '([\\w_:\\?=#&@/;.~-]*))["\'`]%', 'localurl_to_jumpurl', $messagehtml); } require_once 'phpmailer/class.phpmailer.php'; $mail = new phpmailer(); // Leaving this commented out - there's no reason for people to know this //$mail->Version = 'Mahara ' . get_config('release'); $mail->PluginDir = get_config('libroot') . 'phpmailer/'; $mail->CharSet = 'UTF-8'; $smtphosts = get_config('smtphosts'); if ($smtphosts == 'qmail') { // use Qmail system $mail->IsQmail(); } else { if (empty($smtphosts)) { // use PHP mail() = sendmail $mail->IsMail(); } else { $mail->IsSMTP(); // use SMTP directly $mail->Host = get_config('smtphosts'); if (get_config('smtpuser')) { // Use SMTP authentication $mail->SMTPAuth = true; $mail->Username = get_config('smtpuser'); $mail->Password = get_config('smtppass'); } } } if (get_config('bounces_handle') && isset($mailinfo->owner)) { $mail->Sender = generate_email_processing_address($mailinfo->owner, $userto); } if (empty($userfrom) || $userfrom->email == get_config('noreplyaddress')) { if (empty($mail->Sender)) { $mail->Sender = get_config('noreplyaddress'); } $mail->From = get_config('noreplyaddress'); $mail->FromName = isset($userfrom->id) ? display_name($userfrom, $userto) : get_config('sitename'); $customheaders[] = 'Precedence: Bulk'; // Try to avoid pesky out of office responses $messagetext .= "\n\n" . get_string('pleasedonotreplytothismessage') . "\n"; if ($messagehtml) { $messagehtml .= "\n\n<p>" . get_string('pleasedonotreplytothismessage') . "</p>\n"; } } else { if (empty($mail->Sender)) { $mail->Sender = $userfrom->email; } $mail->From = $userfrom->email; $mail->FromName = display_name($userfrom, $userto); } $replytoset = false; if (!empty($customheaders) && is_array($customheaders)) { foreach ($customheaders as $customheader) { $mail->AddCustomHeader($customheader); if (0 === stripos($customheader, 'reply-to')) { $replytoset = true; } } } if (!$replytoset) { $mail->AddReplyTo($mail->From, $mail->FromName); } $mail->Subject = substr(stripslashes($subject), 0, 900); if ($to = get_config('sendallemailto')) { // Admins can configure the system to send all email to a given address // instead of whoever would receive it, useful for debugging. $mail->addAddress($to); $notice = get_string('debugemail', 'mahara', display_name($userto, $userto), $userto->email); $messagetext = $notice . "\n\n" . $messagetext; if ($messagehtml) { $messagehtml = '<p>' . hsc($notice) . '</p>' . $messagehtml; } $usertoname = display_name($userto, $userto, true) . ' (' . get_string('divertingemailto', 'mahara', $to) . ')'; } else { $usertoname = display_name($userto, $userto); if (empty($userto->email)) { throw new EmailException("Cannot send email to {$usertoname} with subject {$subject}. User has no primary email address set."); } $mail->AddAddress($userto->email, $usertoname); $to = $userto->email; } $mail->WordWrap = 79; if ($messagehtml) { $mail->IsHTML(true); $mail->Encoding = 'quoted-printable'; $mail->Body = $messagehtml; $mail->AltBody = $messagetext; } else { $mail->IsHTML(false); $mail->Body = $messagetext; } if ($mail->Send()) { if ($logfile = get_config('emaillog')) { $docroot = get_config('docroot'); @($client = (string) $_SERVER['REMOTE_ADDR']); @($script = (string) $_SERVER['SCRIPT_FILENAME']); if (strpos($script, $docroot) === 0) { $script = substr($script, strlen($docroot)); } $line = "{$to} <- {$mail->From} - " . str_shorten_text($mail->Subject, 200); @error_log('[' . date("Y-m-d h:i:s") . "] [{$client}] [{$script}] {$line}\n", 3, $logfile); } // Update the count of sent mail update_send_count($userto); return true; } throw new EmailException("Couldn't send email to {$usertoname} with subject {$subject}. " . "Error from phpmailer was: " . $mail->ErrorInfo); }
if (!isset($error_message) && !$mail->ValidateAddress($email)) { $error_message = "Invalid Email Address"; } if (!isset($error_message)) { $email_body = ""; $email_body .= "Name: " . $name . "\n"; $email_body .= "Email: " . $email . "\n"; $email_body .= "Suggested Item\n"; $email_body .= "Category: " . $category . "\n"; $email_body .= "Title: " . $title . "\n"; $email_body .= "Format: " . $format . "\n"; $email_body .= "Genre: " . $genre . "\n"; $email_body .= "Year: " . $year . "\n"; $email_body .= "Details: " . $details . "\n"; $mail->setFrom($email, $name); $mail->addAddress('*****@*****.**', 'Daisho'); // Add a recipient $mail->isHTML(false); // Set email format to HTML $mail->Subject = 'Personal Media Library Suggestion from ' . $name; $mail->Body = $email_body; if ($mail->send()) { header("location:suggest.php?status=thanks"); exit; } $error_message = 'Message could not be sent.'; $error_message .= 'Mailer Error: ' . $mail->ErrorInfo; } } $pageTitle = "Suggest a Media Item"; $section = "suggest";
function send_mail() { require 'phpmailer/PHPMailerAutoload.php'; $email = ""; $mail = new phpmailer(); $mail->isSMTP(); $mail->Host = 'smtp.gmail.com'; $mail->SMTPAuth = true; $mail->Username = '******'; $mail->Password = '******'; $mail->SMTPSecure = 'tls'; $mail->Port = 587; $mail->setFrom('*****@*****.**', 'Mailer'); $mail->addAddress('*****@*****.**', 'user'); $mail->isHTML(true); $mail->Subject = 'The code works'; $mail->Body = 'This email is coming from <b> GLOBAL STYLING SALONS !! </b>'; $mail->AltBody = 'This is the body in plain text for non-HTML mail clients'; if (!$mail->send()) { echo 'Message could not be sent.'; echo 'Mailer Error: ' . $mail->ErrorInfo; } else { echo 'Message has been sent to your E-Mail address'; } }
$mail = new phpmailer(); $mail->isSMTP(); // Set mailer to use SMTP $mail->Host = SMTP_HOST; // Specify main and backup SMTP servers $mail->SMTPAuth = SMTP_AUTH; // Enable SMTP authentication $mail->Username = SMTP_USERNAME; // SMTP username $mail->Password = SMTP_PASSWORD; // SMTP password $mail->SMTPSecure = SMTP_SECURE; // Enable TLS encryption, `ssl` also accepted $mail->Port = SMTP_PORT; // TCP port to connect to $mail->From = $from; $mail->FromName = APP_TITLE; $mail->addAddress($to); // Name is optional $mail->isHTML(true); // Set email format to HTML $mail->Subject = $subject; $mail->Body = $html_text; $mail->send(); $result = array("error" => false, "error_code" => ERROR_SUCCESS); } } } echo json_encode($result); exit; }
/* get id for user */ require 'connection.php'; $query = $conn->prepare("SELECT email FROM messages WHERE id=?"); $query->bindValue(1, $id, PDO::PARAM_INT); $query->execute(); $result = $query->fetch(PDO::FETCH_ASSOC); extract($result); require_once 'phpmailer/PHPMailerAutoload.php'; $m = new phpmailer(); $m->isSMTP(); $m->SMTPAuth = true; $m->Host = 'smtpout.secureserver.net'; $m->username = '******'; $m->password = '******'; $m->SMTPSecure = 'ssl'; $m->Port = '465'; $m->From = '*****@*****.**'; $m->FromName = 'pixllart.com'; $m->addReplyTo('', ''); $m->addAddress($email, ''); $m->isHtml(true); $m->subject = 'frist message'; $m->Body = '<p>$msg</p><br><br> <img src="image/' . $img_name . '">'; $m->AltBody = ''; if ($m->send()) { echo "sent"; } else { echo $m->ErrorInfo; }
/** * Always use this function for all emails to users * * @param object $userto user object to send email to. must contain firstname,lastname,preferredname,email * @param object $userfrom user object to send email from. If null, email will come from mahara * @param string $subject email subject * @param string $messagetext text version of email * @param string $messagehtml html version of email (will send both html and text) * @param array $customheaders email headers * @throws EmailException */ function email_user($userto, $userfrom, $subject, $messagetext, $messagehtml = '', $customheaders = null) { if (!get_config('sendemail')) { // You can entirely disable Mahara from sending any e-mail via the // 'sendemail' configuration variable return true; } if (empty($userto)) { throw new InvalidArgumentException("empty user given to email_user"); } require_once 'phpmailer/class.phpmailer.php'; $mail = new phpmailer(); // Leaving this commented out - there's no reason for people to know this //$mail->Version = 'Mahara ' . get_config('release'); $mail->PluginDir = get_config('libroot') . 'phpmailer/'; $mail->CharSet = 'UTF-8'; $smtphosts = get_config('smtphosts'); if ($smtphosts == 'qmail') { // use Qmail system $mail->IsQmail(); } else { if (empty($smtphosts)) { // use PHP mail() = sendmail $mail->IsMail(); } else { $mail->IsSMTP(); // use SMTP directly $mail->Host = get_config('smtphosts'); if (get_config('smtpuser')) { // Use SMTP authentication $mail->SMTPAuth = true; $mail->Username = get_config('smtpuser'); $mail->Password = get_config('smtppass'); } } } if (empty($userfrom)) { $mail->Sender = get_config('noreplyaddress'); $mail->From = $mail->Sender; $mail->FromName = get_string('emailname'); $customheaders[] = 'Precedence: Bulk'; // Try to avoid pesky out of office responses $messagetext .= "\n\n" . get_string('pleasedonotreplytothismessage') . "\n"; if ($messagehtml) { $messagehtml .= "\n\n<p>" . get_string('pleasedonotreplytothismessage') . "</p>\n"; } } else { $mail->Sender = $userfrom->email; $mail->From = $mail->Sender; $mail->FromName = display_name($userfrom, $userto); } $replytoset = false; if (!empty($customheaders) && is_array($customheaders)) { foreach ($customheaders as $customheader) { $mail->AddCustomHeader($customheader); if (0 === stripos($customheader, 'reply-to')) { $replytoset = true; } } } if (!$replytoset) { $mail->AddReplyTo($mail->From, $mail->FromName); } $mail->Subject = substr(stripslashes($subject), 0, 900); if ($to = get_config('sendallemailto')) { // Admins can configure the system to send all email to a given address // instead of whoever would receive it, useful for debugging. $mail->addAddress($to); $notice = get_string('debugemail', 'mahara', display_name($userto, $userto), $userto->email); $messagetext = $notice . "\n\n" . $messagetext; if ($messagehtml) { $messagehtml = '<p>' . hsc($notice) . '</p>' . $messagehtml; } } else { $usertoname = display_name($userto, $userto); $mail->AddAddress($userto->email, $usertoname); } $mail->WordWrap = 79; if ($messagehtml) { $mail->IsHTML(true); $mail->Encoding = 'quoted-printable'; $mail->Body = $messagehtml; $mail->AltBody = $messagetext; } else { $mail->IsHTML(false); $mail->Body = $messagetext; } if ($mail->Send()) { return true; } throw new EmailException("Couldn't send email to {$usertoname} with subject {$subject}. " . "Error from phpmailer was: " . $mail->ErrorInfo); }