/** * Send the mail. * * @param Midas_Mail $mail mail instance * @throws Midas_Service_AppEngine_Exception */ public function sendMail(Midas_Mail $mail) { if (is_null($this->_client)) { $this->_client = new \google\appengine\api\mail\Message(); } $this->_client->addBcc($mail->getBcc()); $this->_client->addCc($mail->getCc()); $this->_client->addTo($mail->getTo()); $this->_client->setHtmlBody($mail->getBodyHtml(true)); $this->_client->setReplyTo($mail->getReplyTo()); $this->_client->setSender($mail->getFrom()); $this->_client->setSubject($mail->getSubject()); $this->_client->setTextBody($mail->getBodyText(true)); try { $this->_client->send(); } catch (\Exception $exception) { throw new Midas_Service_AppEngine_Exception($exception); } }
function sendMail($email, $url) { try { $message = new Message(); $message->setSender("*****@*****.**"); $message->addTo($email); $message->setSubject("Forgot Password"); $message->setTextBody('Please visit the following link to reset your password. ' . $url); $message->send(); } catch (InvalidArgumentException $e) { // ... } }
function contact() { if ($_SERVER["REQUEST_METHOD"] == "POST") { if ($_POST["email"] && $_POST["subject"] && $_POST["content"]) { $msg = new Message(); $msg->setSender("*****@*****.**"); $msg->addTo("*****@*****.**"); $msg->setSubject("[NKR] " . $_POST["subject"]); $msg->setTextBody($_POST["email"] . "\n\n" . $_POST["content"]); $msg->send(); } else { http_response_code(422); } } }
function contact() { if ($_SERVER["REQUEST_METHOD"] == "POST") { if ($_POST["email"] && $_POST["subject"] && $_POST["content"]) { $msg = new Message(); $msg->setSender("*****@*****.**"); $msg->addTo("*****@*****.**"); $msg->setSubject("[MrKimOnTour] " . $_POST["subject"]); $msg->setTextBody($_POST["email"] . "\n\n" . $_POST["content"]); $msg->send(); } else { http_response_code(422); } } }
public function try_to_send_notification() { try { $message = new Message(); //$message->setSender("*****@*****.**"); $message->addTo("*****@*****.**"); $message->setSubject("New Photo Gallery Comment"); $created = datetime_to_text($this->created); $message->setTextBody("\nA new comment has been received in the Photo Gallery.\n\n At {$created}, {$this->author} wrote:\n\n{$this->body}"); //$message->addAttachment('image.jpg', $image_data, $image_content_id); $message->send(); } catch (InvalidArgumentException $e) { echo "erro in sending email"; } }
function sendMail($msg, $sub = "zouk-calendar app") { try { $message = new Message(); $message->setSender("*****@*****.**"); //$message->setSender("*****@*****.**"); $message->addTo("*****@*****.**"); $message->setSubject($sub); $message->setTextBody($msg); $message->send(); } catch (InvalidArgumentException $e) { syslog(LOG_ERR, "Email send failed: " . $e); } }
public function testSetTextBody() { $message = new Message(); $this->setExpectedException("InvalidArgumentException", "Plain text given is not a string (Actual type: array)."); $message->setTextBody(array("text")); }
<?php use google\appengine\api\mail\Message; $title = "Contact"; $msgAlert = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { if ($_POST["email"] && $_POST["subject"] && $_POST["content"]) { $msg = new Message(); $msg->setSender("*****@*****.**"); $msg->addTo("*****@*****.**"); $msg->setSubject("[nakhonratchasima-nkr] " . $_POST["subject"]); $msg->setTextBody($_POST["email"] . "\n\n" . $_POST["content"]); $msg->send(); $msgAlert = <<<END <div class="alert alert-success"> Your email has been sent. </div> END; } else { $msgAlert = <<<END <div class="alert alert-warning"> All fields are required. </div> END; } } $content = <<<END <div class="container"> <div class="row" > <div class="col-lg-12"> <center><h1 class="page-header">ติดต่อเรา</h1></center>
public function DDE_Dep_Exctsubmit($shturl,$selectedunit,$customername,$checkarray,$selectedsheet,$customermail,$customeridname,$UserStamp){ $test=array(); $submit_array=array();$submitarray=array(); $sub_exequery ="SELECT ETD .ETD_EMAIL_SUBJECT,ETD. ETD_EMAIL_BODY FROM EMAIL_TEMPLATE_DETAILS ETD ,EMAIL_TEMPLATE ET WHERE (ET .ET_ID=ETD .ET_ID) AND ET_EMAIL_SCRIPT='DEPOSIT DEDUCTION'"; $sub_rs = $this->db->query($sub_exequery); $subject_db=$sub_rs->row()->ETD_EMAIL_SUBJECT; $message_db=$sub_rs->row()->ETD_EMAIL_BODY; $rcontent = $customername." - ".$selectedunit; $subject =str_replace('[UNIT_NO - CUSTOMER_NAME]',$rcontent,$subject_db); $body =str_replace('[UNIT_NO- CUSTOMER_NAME]',$rcontent,$message_db); $emailindex = strstr($customermail,'@',true); $eusername = strtoupper($emailindex); $body = str_replace('[MAILID_USERNAME]',$eusername,$body); $this->load->model('EILIB/Mdl_eilib_common_function'); $EmailDisplayname=$this->Mdl_eilib_common_function->Get_MailDisplayName('DEPOSIT_DEDUCTION'); $pdfheader=$selectedunit.'-'.$customername; for($k=0;$k<count($checkarray);$k++){ $data5=array('DDE_flag'=>6,'shturl'=>$shturl,'selectedunit'=>$selectedunit,'customername'=>$customername,'checkarray'=>$checkarray[$k], 'selectedsheet'=>$selectedsheet,'customeridname'=>$customeridname); $submit_array=$this->Mdl_eilib_common_function->Func_curl($data5); $submitarray[]=json_decode($submit_array,true); } try { $message = new Message(); $message->setSender($EmailDisplayname.'<'.$UserStamp.'>'); $message->addTo($customermail); $message->setSubject($subject); $message->setTextBody($body); for ($i = 0; $i < count($submitarray); $i++) { $test[]=$i+1; $data = implode(array_map("chr", $submitarray[$i][0])); $message->addAttachment($pdfheader . '.pdf', $data); } $message->send(); $data5=array('DDE_flag'=>7); $response=$this->Mdl_eilib_common_function->Func_curl($data5); return $submitarray; } catch (InvalidArgumentException $e) { return $e->getMessage(); } }
<?php use google\appengine\api\mail\Message; $name = htmlspecialchars($_POST["name"]); $email = htmlspecialchars($_POST["email"]); $message = htmlspecialchars($_POST["message"]); $subject = "Feedback received from: " . $name; $emailBody = "From: " . $name . "\nEmail: " . $email . "\n\nMessage:\n" . $message; try { $message = new Message(); $message->setSender("*****@*****.**"); $message->addTo("*****@*****.**"); $message->addTo("*****@*****.**"); $message->addTo("*****@*****.**"); $message->setSubject($subject); $message->setTextBody($emailBody); $message->send(); } catch (InvalidArgumentException $e) { echo $e; } echo "complete";
$email_message = <<<EMAIL guest1: {$submitted['guest1']} guest2: {$submitted['guest2']} coming: {$submitted['coming']} meal_beef: {$submitted['meal_beef']} meal_fish: {$submitted['meal_fish']} meal_veggie: {$submitted['meal_veggie']} dietary_restrictions: {$submitted['dietary_restrictions']} brunch: {$submitted['brunch']} song: {$submitted['song']} message: {$submitted['message']} EMAIL; try { $message = new Message(); $message->setSender('*****@*****.**'); $message->addTo('*****@*****.**'); $message->setSubject("RSVP to Beth & Ian's Wedding"); $message->setTextBody($email_message); if (!empty($selfie)) { $message->addAttachment($selfie['name'], $selfie['data']); } $message->send(); include 'views/thankyou.php'; } catch (Exception $e) { $error_message = <<<HTML Couldn't send your message to Beth & Ian. The following error occurred:<br><br> {$e} HTML; include 'views/error.php'; }
$approvalStatus = $_POST["approval"]; $requestedBy = $_POST["requestedBy"]; $requestedApprovedBy = $_POST["requestedApproved"]; $messageToSend = $_POST["sai"]; $requestNo = $_POST["requestNo"]; $requestEmailer = $_POST["reqEmailer"]; // message lines should not exceed 70 characters (PHP rule), so wrap it // send mail try { $message = new Message(); $message->setSender("*****@*****.**"); $message->addTo("*****@*****.**"); $message->addTo("*****@*****.**"); $message->addTo($requestEmailer); if (strcmp($approvalStatus, 'Yes') == 0) { $message->setSubject("Approved Facility request-Request {$requestNo} -Approved by -{$requestedApprovedBy}"); } else { $message->setSubject("Rejected Facility request-Request {$requestNo} -Declined by -{$requestedApprovedBy}"); } $message->setTextBody($messageToSend); $message->send(); echo "Thank you for sending us your Decision!!!"; } catch (InvalidArgumentException $e) { echo "Error Occured sending mail"; echo $e->getMessage(); } } ?>
<?php if (!isset($_POST)) { exit; } use google\appengine\api\mail\Message; $mensajeCuerpo = array(); $mensajeCuerpo[] = "Nombre y Apellido: " . $_POST['var_name']; $mensajeCuerpo[] = "Email: " . $_POST['var_mail']; $mensajeCuerpo[] = "Telefono: " . $_POST['var_phone']; $mensajeCuerpo[] = "Empresa: " . $_POST['var_empresa']; $mensajeCuerpo[] = "Cargo: " . $_POST['var_cargo']; $mensajeCuerpo[] = "Consulta: " . $_POST['var_comments']; $mensajeCuerpo = implode("\n", $mensajeCuerpo); // Notice that $image_content_id is the optional Content-ID header value of the // attachment. Must be enclosed by angle brackets (<>) //$image_content_id = '<image-content-id>'; // Notice that $image_data is the raw file data of the attachment. try { $message = new Message(); $message->setSender("*****@*****.**"); $message->addTo("*****@*****.**"); $message->setSubject("Consulta Web"); $message->setTextBody($mensajeCuerpo); //$message->addAttachment('image.jpg', $image_data, $image_content_id); $message->send(); print "ok"; } catch (InvalidArgumentException $e) { print "error"; }
$values = implode("', '", $escaped_values); $query1 = "INSERT INTO `website_users`({$columns}) VALUES ('{$values}')"; $result2 = mysql_query($query1); if (!$result2) { die('Invalid query: ' . mysql_error()); } // done // Notice that $image_content_id is the optional Content-ID header value of the // attachment. Must be enclosed by angle brackets (<>) // Notice that $image_data is the raw file data of the attachment. try { $message = new Message(); $message->setSender("*****@*****.**"); $message->addTo($email); $message->setSubject("Confirm your Buy 4 Square email address"); $message->setTextBody('Confirm your e-mail address https://buy4square.appspot.com/confirm-email.php?username='******'&code?' . $email_code . ''); $message->send(); } catch (InvalidArgumentException $e) { // ... } $success = '<div class="alert alert-success">You Created an account, please sign in.</div>'; } } } } // Inialize session $form_username = ''; $form_password = ''; if (isset($_POST['login'])) { $form_username = mysql_real_escape_string($_POST['username']); $form_password = mysql_real_escape_string($_POST['password']);
/** * Send email * * This is based on {@see wp_mail()} which is in turn based on PHP's * built-in mail() function. This is typically called from the overriden * version of {@see wp_mail()} below. * * @param string|array $to Array or comma-separated list of email addresses to send message. * @param string $subject Email subject * @param string $message Message contents * @param string|array $headers Optional. Additional headers. * @param string|array $attachments Optional. Files to attach. * * @return bool Whether the email contents were sent successfully. */ function send_mail($to, $subject, $message, $headers = '', $attachments = array()) { // Compact the input, apply the filters, and extract them back out extract(apply_filters('wp_mail', compact('to', 'subject', 'message', 'headers', 'attachments'))); global $phpmailer; if (!is_object($phpmailer) || !is_a($phpmailer, 'Message')) { $phpmailer = new Message(); } $cc = array(); $bcc = array(); // Headers if (empty($headers)) { $headers = array(); } else { if (!is_array($headers)) { // Explode the headers out, so this function can take both // string headers and an array of headers. $tempheaders = explode("\n", str_replace("\r\n", "\n", $headers)); } else { $tempheaders = $headers; } $headers = array(); // If it's actually got contents if (!empty($tempheaders)) { // Iterate through the raw headers foreach ((array) $tempheaders as $header) { if (false === strpos($header, ':')) { if (false !== stripos($header, 'boundary=')) { $parts = preg_split('/boundary=/i', trim($header)); $boundary = trim(str_replace(array("'", '"'), '', $parts[1])); } continue; } // Explode them out list($name, $content) = explode(':', trim($header), 2); // Cleanup crew $name = trim($name); $content = trim($content); switch (strtolower($name)) { // Mainly for legacy -- process a From: header if it's there case 'from': if (false !== strpos($content, '<')) { // So... making my life hard again? $from_name = substr($content, 0, strpos($content, '<') - 1); $from_name = str_replace('"', '', $from_name); $from_name = trim($from_name); $from_email = substr($content, strpos($content, '<') + 1); $from_email = str_replace('>', '', $from_email); $from_email = trim($from_email); } else { $from_email = trim($content); } break; case 'content-type': if (false !== strpos($content, ';')) { list($type, $charset) = explode(';', $content); $content_type = trim($type); if (false !== stripos($charset, 'charset=')) { $charset = trim(str_replace(array('charset=', '"'), '', $charset)); } elseif (false !== stripos($charset, 'boundary=')) { $boundary = trim(str_replace(array('BOUNDARY=', 'boundary=', '"'), '', $charset)); $charset = ''; } } else { $content_type = trim($content); } break; case 'cc': $cc = array_merge((array) $cc, explode(',', $content)); break; case 'bcc': $bcc = array_merge((array) $bcc, explode(',', $content)); break; default: // Add it to our grand headers array $headers[trim($name)] = trim($content); break; } } } } // Empty out the values that may be set $phpmailer->clearBcc(); $phpmailer->clearCc(); $phpmailer->clearReplyTo(); $phpmailer->clearTo(); // From email and name // If we don't have a name from the input headers if (!isset($from_name)) { $from_name = 'App Engine'; } /* If we don't have an email from the input headers default to wordpress@$sitename * Some hosts will block outgoing mail from this address if it doesn't exist but * there's no easy alternative. Defaulting to admin_email might appear to be another * option but some hosts may refuse to relay mail from an unknown domain. See * http://trac.wordpress.org/ticket/5007. */ if (!isset($from_email)) { $from_email = get_option('appengine_email', false); if (!$from_email) { $from_email = get_default_email(); } } // Plugin authors can override the potentially troublesome default // TODO: Currently, App Engine doesn't support a from name. We should // come back to this and fix it if/when it does //$phpmailer->setSender( apply_filters( 'wp_mail_from_name', $from_name ) . " <" . apply_filters( 'wp_mail_from', $from_email ) . ">"); $phpmailer->setSender(apply_filters('wp_mail_from', $from_email)); // Set destination addresses if (!is_array($to)) { $to = explode(',', $to); } foreach ((array) $to as $recipient) { try { // Break $recipient into name and address parts if in the format "Foo <*****@*****.**>" $recipient_name = ''; if (preg_match('/(.*)<(.+)>/', $recipient, $matches)) { if (count($matches) == 3) { $recipient_name = $matches[1]; $recipient = $matches[2]; } } $phpmailer->addTo($recipient, $recipient_name); } catch (Exception $e) { syslog(LOG_DEBUG, 'Mail error: ' . $e->getMessage()); continue; } } // Add any CC and BCC recipients $cc = array_filter($cc); $bcc = array_filter($bcc); if (!empty($cc)) { foreach ((array) $cc as $recipient) { try { // Break $recipient into name and address parts if in the format "Foo <*****@*****.**>" $recipient_name = ''; if (preg_match('/(.*)<(.+)>/', $recipient, $matches)) { if (count($matches) == 3) { $recipient_name = $matches[1]; $recipient = $matches[2]; } } $phpmailer->addCc($recipient, $recipient_name); } catch (Exception $e) { syslog(LOG_DEBUG, 'Mail error: ' . $e->getMessage()); continue; } } } if (!empty($bcc)) { foreach ((array) $bcc as $recipient) { try { // Break $recipient into name and address parts if in the format "Foo <*****@*****.**>" $recipient_name = ''; if (preg_match('/(.*)<(.+)>/', $recipient, $matches)) { if (count($matches) == 3) { $recipient_name = $matches[1]; $recipient = $matches[2]; } } $phpmailer->addBcc($recipient, $recipient_name); } catch (Exception $e) { syslog(LOG_DEBUG, 'Mail error: ' . $e->getMessage()); continue; } } } // Set Content-Type and charset // If we don't have a content-type from the input headers if (!isset($content_type)) { $content_type = 'text/plain'; } $content_type = apply_filters('wp_mail_content_type', $content_type); // Set whether it's plaintext, depending on $content_type if ('text/html' == $content_type) { $phpmailer->setHtmlBody($message); } else { $phpmailer->setTextBody($message); } $phpmailer->setSubject($subject); // If we don't have a charset from the input headers if (!isset($charset)) { $charset = get_bloginfo('charset'); } // Set the content-type and charset //$phpmailer->charsset = apply_filters( 'wp_mail_charset', $charset ); // Set custom headers if (!empty($headers)) { if (isset($headers['MIME-Version'])) { unset($headers['MIME-Version']); } $phpmailer->addHeaderArray($headers); if (false !== stripos($content_type, 'multipart') && !empty($boundary)) { $phpmailer->addHeaderArray('Content-Type', sprintf("%s;\n\t boundary=\"%s\"", $content_type, $boundary)); } } if (!empty($attachments)) { foreach ($attachments as $attachment) { try { $name = basename($attachment); $data = file_get_contents($attachment); $phpmailer->addAttachment($name, $data); } catch (Exception $e) { syslog(LOG_DEBUG, 'Mail error: ' . $e->getMessage()); continue; } } } // Send! $phpmailer->send(); return true; }