Jump to content

Search the Community

Showing results for tags 'mail()'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (Dreamweaver, Zend, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 2 results

  1. I am using magento for sending mail with condition, My code: <?php class Gta_MerchantNotification_Model_Observer { public function merchantremainder($Observer) { $order = $Observer->getEvent()->getOrder(); $order_details = $order->getAllVisibleItems(); $itemData = array(); foreach ($order_details as $list) { $incrementid = $order->getIncrementId(); $sku = $list->getsku(); $name = $list->getName(); $price = $list->getPrice(); $Qty = $list->getQtyOrdered(); $extra = $order->getIncrementId(); $message = " <tr> <!-- <td>$incrementid</td> --> <td>$sku</td> <td>$name</td> <td>$price</td> <td>$Qty</td> </tr>"; $itemData[$list->getId()] = $message; } $finalMessage = " <p>Order Id : $incrementid</p> <table border='1'> <tr> <!-- <th>Id</th> --> <th>Sku</th> <th>Product name</th> <th>Price</th> <th>Qty Ordered</th> </tr>"; if (!empty($itemData)) { foreach ($itemData as $data) { $finalMessage .= $data; } $finalMessage .= "</table>"; $this->sendMail($finalMessage); } } public function sendMail($message) { $body ="$message"; $emailTemplate = Mage::getModel('core/email'); $emailTemplate->setFromName('abc'); $emailTemplate->setBody($body); $emailTemplate->setSubject("Custom Email from observer"); $emailTemplate->setType('html'); $emailTemplate->setToEmail('abc@gmail.com'); $emailTemplate->send(); } } ?> Output : If order placed mail send to abc@gmail.com. How to set email sender based on SKU $sku from order. I want : 1) If SKU starts with 2, email should go to the mail id abc@gmail.com, screenshot : 2) If SKU starts with 3, email should go to the mail id xyz@gmail.com, screenshot : 3) If SKU starts with 4, email should go to the mail id qwe@gmail.com, screenshot : FYI - If an order contains 10 items email should go separately based on SKU. But an order id the same must include all the emails.
  2. Quite simple my mail is failing to send. The $_POST variable is not echo ing after being reassigned to $message and $email is not appearing either to satisfy the mail() function. I know i' <?php require_once __DIR__ . '/header.php'; require_once __DIR__ . '/includes/class_mtg_paginate.php'; $opts = ['grpgusers', 'gdemails']; $names = ['MS', 'GD']; $view = isset($_GET['view']) && in_array($_GET['view'], $opts) ? $_GET['view'] : 'grpgusers'; if (!$user_class->admin) $mtg->error("You don't have access"); if (array_key_exists('ms', $_POST)) { $db->query("SELECT id, email FROM grpgusers ORDER BY id ASC LIMIT 2"); $db->execute(); $rows = $db->fetch_row(); $success = 0; $failure = 0; echo 'Sending...<br />'; $message = stripslashes($_POST['message']); $headers = 'From: webmaster@example.com' . "\r\n" . 'Reply-To: webmaster@example.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); foreach ($rows as $row) { $email = $row['email']; if (mail("$email", "A message from MS", "$message", "$headers")) ++$success; else ++$failure; } $mtg->success("Message sent to " . $mtg->format($success) . " user" . $mtg->s($success) . ". Failed to send to " . $mtg->format($failure) . " user" . $mtg->s($failure)); } if (array_key_exists('gd', $_POST)) { $db->query("SELECT id, email FROM gdemails ORDER BY id ASC LIMIT 2"); $db->execute(); $rows = $db->fetch_row(); $success = 0; $failure = 0; echo 'Sending...<br />'; $message = stripslashes($_POST['message']); foreach ($rows as $row) { $email = $row['email']; if (mail("$email", "A message from MS", "$message")) ++$success; else ++$failure; } $mtg->success("Message sent to " . $mtg->format($success) . " user" . $mtg->s($success) . ". Failed to send to " . $mtg->format($failure) . " user" . $mtg->s($failure)); } $pages = new Paginator(); if($_GET['view'] == "grpgusers") { $db->query("SELECT COUNT(id) FROM grpgusers"); $submit = "ms"; } else { $db->query("SELECT COUNT(id) FROM gdemails"); $submit = "gd"; } $db->execute(); $pages->items_total = $db->fetch_single(); $pages->mid_range = 5; $pages->paginate(); ?> <tr><th class='contenthead'>Mass Email</th></tr> <tr><td class='contentcontent'> <form action='staff_mail.php' method='post'> <table id='mttable' width='100%'> <tr> <th width='25%'>Message</th> <td width='75%'><textarea name='message' rows='10' cols='60'></textarea></td> </tr> <tr> <td colspan='2' class='center'><input type='submit' name='<?php echo $submit; ?>' value='Send Email' /></td> </tr> </table> </form> <br /> <div class='paginate'><?php echo $pages->display_pages(); ?></div> <br /> <form action="staff_mail.php" method="get"> <table width="100%" id='mttable'> <tr> <th width='25%'>Emailer List</th> <td width='75%'><select name='view' onchange='this.form.submit()'> <option value='grpgusers'>Select...</option> <?php $c = 0; foreach ($opts as $opt) { printf("<option value='%s'>%s</option>", $opt, $names[$c]); $c++; } ?></select></td> </tr> </table> </form> <br /> <table id='mttable' width='100%'> <tr> <td colspan='5' class='center'><?php if($_GET['view'] == "grpgusers") { echo "MS"; } else { echo "GD"; } ?> Emails</td> </tr> <tr> <th width='5%'>ID</th> <th width='35%'>Username</th> <th width='48%'>Email</th> <th width='12%'>Action</th> </tr><?php if($_GET['view'] == "grpgusers") { $db->query("SELECT id, username, email FROM grpgusers ORDER BY id ASC " . $pages->limit); } else { $db->query("SELECT * FROM gdemails ORDER BY emailid ASC " . $pages->limit); } $db->execute(); $rows = $db->fetch_row(); foreach ($rows as $row) { ?><tr> <td><?php echo $row['id']; ?></td> <td><?php echo $row['username']; ?></td> <td><?php echo $row['email']; ?></td> <td><?php echo '[Delete]'; ?></td> </tr><?php } ?></table> <br /> <div class='paginate'><?php echo $pages->display_pages(); ?></div> </td></tr><?php require_once __DIR__ . '/footer.php'; m missing something dumb so be gentle with me.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.