PHP - Problem With Sending Mail With Pear (mail/mime.php)
Hello to all out there!
this is my first post,so my question may sound a bit simple. :] I am studying PHP and MySQL and I tried to make a mailing form based on a mysql database. My problem occured when I tried to use the PEAR mail object. Here is my code: // THE INCLUDED FILES require_once ("attach_file.php" ); require_once ("Mail.php" ); require_once ("Mail\mime.php" ); //THE VARIABLES TAKEN FROM THE HTML FORM OR JUST CREATED FOR THE CONSTRUCTION OF THE EMAIL $my_email = "something@gmail.com"; $email_subject = mysql_real_escape_string(trim( $_POST['email_subject']),$server_connect ); $email_body = mysql_real_escape_string(trim( $_POST['email_body'] ),$server_connect ); $attached_file = $destination ; // the $destination variable comes from the copy() function in attach_file.php $username = "the_username@gmail.com"; $password = "the_password"; $host = "smtp.gmail.com"; $attach = new Mail_mime(); $attach -> addAttachment($attached_file); $email_body = $attach->get(); $extraheaders = array('from'=>$my_email,'to'=>$email_etaireias,'subject'=>$email_subject,'Bcc'=>$email_etaireias); $headers = $attach -> $headers($extraheaders); // HERE GIVES ME AN ERROR!!! -->Fatal error: Method name must be a string $smtp_info = array('host'=>$host,'auth'=>TRUE,'username'=>$username,'password'=>$password); $smtp = Mail::factory('smtp',$smtp_info); //loop through every single line of the database until there are no more lines with data //and store each line in 3 different variables that i can use while ( $row = mysql_fetch_array($result) ) { $onoma_etaireias = $row['onoma_etaireias']; $email_etaireias = $row['email_etaireias']; $website_etaireias = $row['website_etaireias']; } //construct the mail function . The @ is supressing the errors created .remove it and they will be shown. $mail = @$smtp->send($email_etaireias,$headers,$email_body); As i searched here and there for a solution, i found that it has something to do with the way the mail-mime object creates the body of the email . I also tried to find a solution from the PEAR documentation. do i create the headers someway wrong????? Similar TutorialsI have a notification system that notifies users of new comments, inside the email I have images, some of the logo, some of different people, everything shows up fine on my computer (yahoo email), however in the iPhones email application no images show up, there are just the blue squares with the question marks in them. I'm not sure what I'm missing. Code: [Select] $from = "Kithell <notifications@kithell.com>"; $headers = "From:" . $from ."\r\n"; $headers .= 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $subject = name($from_id, 'fl').$action; $message = '<html><body> <style>@charset "utf-8"; /* CSS Document */ .e-container { background-color: #FFF;position: relative;width: 90%;min-height:1px;margin-right: auto;margin-left: auto; } .e-container .e-m-header { padding: 2px; background-image: url(http://www.kithell.com/assets/tall-grey-header.png); background-repeat: repeat-x; border: 1px solid #CCC; background-position: bottom; display: block; text-align: center; } .e-container p { font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; color: #666; vertical-align: text-top; display: inline-block; } .e-container .e-usr-photo { display: inline-block; margin: 10px; float: left; background-color: #F4F4F4; } .e-container p a { font-weight: bold; color: #3F60A3; text-decoration: underline; padding: 0px; float: left; margin-top: 0px; margin-right: 5px; margin-bottom: 0px; margin-left: 0px; } .e-container .e-quotes { font-size: 20px; font-weight: bold; color: #999; font-family: Tahoma, Geneva, sans-serif; display: block; padding: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 75px; margin-top:10px; } .e-container .e-message { font-size: 13px; color: #333; padding: 0px; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 10px; clear: none; display: inline; }</style> <div class="e-container"><div class="e-m-header"><img src="http://www.kithell.com/assets/kithell-logo.png" /></div><img class="e-usr-photo" src="http://www.kithell.com/'.photo($from_id, 55).'" /><br /><p><a target="_blank" href="http://www.kithell.com/#/profile&id='.$from_id.'">'.name($from_id, "fl").' </a> '.$action.'<div class="e-quotes">"<p class="e-message">'.nl2br(htmlentities(stripslashes($message))).'</p>"</div></p></div></body></html>'; mail($to,$subject,$message,$headers); I'm setting up a newsletter thing for my website. I have a newsletter table in MySQL: Quote +----------------+------+--------+ | email | mens | womens | +----------------+------+--------+ | test2@test.com | 1 | 1 | | test1@test.com | 1 | 0 | +----------------+------+--------+ I am using a HTML form and this PHP code I learn't from the manual, which sends out e-mail's. PHP: if ($_POST['newsletter'] == 'Mens') { $to = ''; $subject = $_POST['subject']; $body = $_POST['body']; $header = 'From: Me Someone <me@someone.com>'; mail($to, $subject, $body, $header); } What I want to do with the above code is send out an e-mail to all the e-mails in my MySQL database that are tagged '1' under mens. How would I go about doing this? I'm guessing I will have to use a MySQL query in the $to = ''; that goes something like this: $to = '$query (select from `newsletters` where `email` = 1'); ? system: vista ultimate sp2 IIS 7 server installed and running PHP 5 fastCGI im not sure if this is within the purview of the forum but you all seem like smart people with an expertise in this area. i have a web site http://penumbraproductions.dyndns-remote.com/ . it is hosted locally on my desktop using the above mentioned IIS7 server options using dyndns to list the url cause my ISP has DHCP without static ip's for non-business accounts that has a contact form... form mail. i've tried numerous php codes to get it to send mail to my email account but none of them are working my IIS smtp setting a email to: archaismic@gmail.com smtp server: smtp.gmail.com port number: 465 using login credentials i've also tried to configuring the smtp options in IIS to dump the mail to a folder on my computer which also did not work attached is the feedback.php file im currently working with minus the captcha private key and the code for the form i'm using is: Code: [Select] <form action="feedback.php" method="post"> <table border="0" cellpadding="8" cellspacing="8"> <tr><td><label for="tswname">Name</label>:</td><td><input type="text" name="fullname" id="tswname" size="25" /></td></tr> <tr><td><label for="tswemail">Email address</label>:</td><td><input type="text" id="tswemail" name="email" size="25" /></td></tr> <tr> <td colspan="2"> <label for="tswcomments">Comments</label><br /> <textarea rows="15" cols="45" name="comments" id="tswcomments"></textarea> </td> </tr> <tr> <td align="center" colspan="2"> <script type="text/javascript" src="http://api.recaptcha.net/challenge?k=6LcYjcASAAAAAH1NwZ0IH_TUO4XDANZqWu3Ei9yh"></script> <noscript> <iframe src="http://api.recaptcha.net/noscript?k=6LcYjcASAAAAAH1NwZ0IH_TUO4XDANZqWu3Ei9yh" height="300" width="500" frameborder="0" title="CAPTCHA test"></iframe> <br /> <label for="tswcaptcha">Copy and paste the code provided in above box he </label><br /> <textarea name="recaptcha_challenge_field" id="tswcaptcha" rows="3" cols="40"></textarea> <input type="hidden" name="recaptcha_response_field" value="manual_challenge" /> </noscript> </td> </tr> <tr> <td align="center" colspan="2"> <input type="submit" value="Send Feedback" /> </td> </tr> </table> </form> hi all new to php and having a sturggle with email.
I have a a form that when completed I wish to auto email the results to a new member simple enough . i also create a image with their unique name and member type and attach this to the email. I can attach the image and send an html email however I wish to send a plain text email along with this.
here lies the problem.
$to = $email ; $subject = 'some subject'; $bound_text = "010103689954"; $bound = "--".$bound_text."\r\n"; $bound_last = "--".$bound_text."--\r\n"; $headers = "From: <snip email removed>\r\n"; $headers .= "MIME-Version: 1.0\r\n" ."Content-Type: multipart/mixed; boundary=\"$bound_text\""; $message .= "If you can see this MIME than your client doesn't accept MIME types!\r\n" .$bound; /*HTML part of email*/ $message .= "Content-Type: text/html; charset=\"iso-8859-1\"\r\n"; $message .="Content-Transfer-Encoding: 7bit\r\n\r\n"; $message .='<html><b>html version</b></html>\r\n' .$bound; /*Plain Text part of email*/ $message .= "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n"; $message .="Plain text version\r\n" .$bound; /*Attachment part of the email adds jpeg memebrship card*/ $file = file_get_contents("create_membership_card.php?forename=$Forename&surname=$Surname&membership=$Membership"); $message .= "Content-Type: image/jpg; name=\"YourMembershipCard.jpg\"\r\n" ."Content-Transfer-Encoding: base64\r\n" ."Content-disposition: attachment; file=\"YourMembershipCard.jpg\"\r\n" ."\r\n" .chunk_split(base64_encode($file)) .$bound_last; mail($to, $subject, $message, $headers)This will send email in html and attach image but I can not get it to also send the plain/test version. example page to enter email and see what is sent http://www.hexhamcan....php?page=Email Any help with this would be great thanks in advance hope I have provided enough information Lee ps. great place you have here Edited by mac_gyver, 29 May 2014 - 07:26 PM. removed email address I sent an MIME email to an outlook account using Mail() and the HTML part was placed as an attachment for some reason. I dont get caught by most spam filters (just outlook and my school) but I wanted to get this worked out so I dont get caught by any spam filters. Can someone please take a look at my email system below and let me know if everything looks correct? Just in case you need this; I am using PostFix, Zimbra, running on Debian 6.0 (php5) //add From: header $headers = 'From:' . $from . "\n"; $headers .= 'Reply-To:' . $from . "\n"; $headers .= 'Return-Path:' . $from . "\n"; //specify MIME version 1.0 $headers .= "MIME-Version: 1.0\n"; //unique boundary $boundary = uniqid("market"); //tell e-mail client this e-mail contains//alternate versions $headers .= "Content-Type: multipart/mixed; boundary = $boundary\r\n\r\n"; //plain text version of message $body = "--$boundary\r\n" . "Content-Type: text/plain; charset=ISO-8859-1\r\n" . "Content-Transfer-Encoding: base64\r\n\r\n"; //adds the remove to the string $body .= chunk_split(base64_encode($plaintxt)); //HTML version of message $body .= "--$boundary\r\n" . "Content-Type: text/html; charset=ISO-8859-1\r\n" . "Content-Transfer-Encoding: base64\r\n\r\n"; $body .= chunk_split(base64_encode($htmltxt)); $message = stripcslashes($body); $subject = stripcslashes($subject); mail($to1[$i], $subject, $message, $headers, "-f $from"); Hi Sending mail problem, it going as plain text<?php include("global.php"); $Form_ID = $_GET['Form_ID']; $Page_ID = $_GET['Page_ID']; $Menu_ID = $_GET['Menu_ID']; $website_email = $g_setups[website_email]; $website_name = $Language_Website_Name; $website_link = $g_setups[website_link]; //get the Email Address from the Form Table #Email Address has taken from the Form Table,(may contain more than 1 email IDS) $email = "SELECT * FROM form where Form_ID = ".$Form_ID; $temps_email = $DB_site->query($email); $temp_email = $DB_site->fetch_array($temps_email); $add = explode("\n",$temp_email[Form_Email]); $address_count = count($add); $f=""; $frm = "SELECT * FROM field where Form_ID = ".$Form_ID; $temps = $DB_site->query($frm); while($temp = $DB_site->fetch_array()) { $value=""; //var_dump($_POST); //exit(); $nos = count($_POST["a".$temp[Field_ID]]); if($nos == 1) { $value = $_POST["a".$temp[Field_ID]]; } else { for($i=0;$i<$nos;$i++) { $value = $value.$_POST["a".$temp[Field_ID]][$i]; } } //echo $value; //exit(); $f = $f."<div style=' background-color:gray; clear:left;'><div style='float:left; width:150px; text-align:left; background-color:#f7f4f3;'>".$temp[Field_Name]."</div>". "<div style='float:left; width:350px; text-align:left; background-color:#f7f4f3;'>".$value."</div></div>"; } // Your email subject text $esubject = "Forms"; // Email Content //Get the Form Field Ids and Form Values and Mail It $emailtext = " <div style='width:500px; height=800px'> <div style='background-color:gray;'>Form</div> <div style=''><p>$f</p></div> </div> "; $headers = 'From: '.$website_name .'noreply@'.$website_link.'' . "\r\n" . 'Reply-To: noreply@'.$website_link.'' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); # This sends the email to you for($i=0;$i<$address_count;$i++) { //@mail("$add[$i]", $esubject, $emailtext, $header); mail("$add[$i]", $esubject, $emailtext, $header); //echo "send sucess"; } echo "<meta http-equiv=Refresh content=1;url='none.php?do=pagelink&Page_ID=$Page_ID&Menu_ID=$Menu_ID&mail_msg=sucess'>"; exit; ?> Thanks Here is the code I have so far: <?php include('database.inc.php'); // Our database connectivity file ?> <?php $reminder_date = 't1.reminder_date'; $email = 'lp_reminder_email'; $reminder_name = 't1.reminder_name'; $reminder_details = 't1.reminder_desc'; $result = mysql_query($sql) or die(mysql_error()); $sql = "SELECT t1.`reminder_id` , t1.`reminder_name` , t1.`reminder_desc` , t1.`reminder_date` , t1.`reminder_email` , lp4.`email` AS `lp_reminder_email` FROM `reminder_events` AS t1 LEFT OUTER JOIN `authorize` AS lp4 ON ( t1.`reminder_email` = lp4.`email` ) WHERE reminder_date <= NOW() ORDER BY `reminder_date` ASC"; $result = 'mysql_num_rows'; while( $row = mysql_fetch_array( $result ) ) if( !empty( $nr ) ) ?> <?php $to = $row[$email]; $from = $row[$email]; $headers = $from; $subject = $row[$reminder_name]; $body = $row[$reminder_details]; { $send = @mail($to, $subject, $body, $headers); } ?> The sql query when run through phpMyAdmin returns a result. When I open this in the browser, it says "Query is empty". Anyone want to help a newb out and show me what I'm doing wrong? I'd like for it to pull the data out of these fields and send it via e-mail. What would be even better is if I could get it to do this the day before the `reminder_date`. I can set it up so cron runs the script, I just need to get the script to work first. Thanks in advance for your help. Hi all, Will reading on php.net about the famous mail() function somewhere in the notes, the author mentions to use Pear:: for sending larger amounts of email. Since I have never done anything with pear, I was wondering if it weren't better to start out with Pear, since it's more a long term thinking solution or shoudl i first start with mail(). I have read the Pear pagess, and all I saw were delayed mail sending and sending in larger quantities. If someone could maybe advise me on would could be a best practise i would love to hear I am trying to send an email to my gmail account using Mail SMTP. With the following code: <?php include 'incl/php/Mail.php'; $recipients = 'xxxxxxxx@gmail.com'; $headers['From'] = 'no-reply@newzstand.us'; $headers['To'] = $recipients; $headers['Subject'] = 'Test message'; $headers['Date'] = date('r', time()); $headers['Message-Id'] = '<'. microtime(true).'@newzstand.us>'; $body = 'Test message'; $domain = preg_replace("/.*@([^@]*)/", '\1', $recipients); $mxrr = getmxrr($domain, $mxhosts); $params['host'] = $mxhosts[0]; $params['localhost'] = 'mail.newzstand.us'; $params['username'] = 'no-reply'; $params['password'] = 'xxxxxxx'; // Create the mail object using the Mail::factory method $mail_object =& Mail::factory('smtp', $params); $send = $mail_object->send($recipients, $headers, $body); if (PEAR::isError($send)){ echo $send->getMessage(); }else{ echo 'No error'; } ?> I get the following message: Failed to connect to alt2.gmail-smtp-in.l.google.com:25 [SMTP: Failed to connect socket: Connection refused (code: -1, response: )] Why is Gmail refusing me? I recently changed something in an old script of mine and it doesn't work properly anymore. I don't know what I did, and I don't have a backup, oops! The code below is supposed to take inputs from a web form and turn them into an e-postcard, attaching and sending it as a jpeg on an email, ideally to be displayed inline. $name = $_POST['sendername']; $to = $_POST['recipient']; $from = $_POST['senderemail']; $subject = basename( $name)." has sent you a jCard!"; $message = $_POST['text']; $bcc = $_POST['bcc']; $finalimage = $_POST['finalimage']; //create a boundary string. It must be unique //so we use the MD5 algorithm to generate a random hash $random_hash = md5(date('r', time())); //define the headers we want passed. Note that they are separated with rn $headers = "From: ".$name." <".$from.">\r\nReply-To: ".$name." <".$from.">\r\nBcc: ".$bcc."\r\nX-Mailer: PHP/".phpversion();""; //add boundary string and mime type specification $headers .= "\r\nContent-Type: multipart/mixed; boundary='PHP-mixed-".$random_hash."'"; //read the attachment file contents into a string, //encode it with MIME base64, //and split it into smaller chunks $attachment = chunk_split(base64_encode(file_get_contents($finalimage))); //define the body of the message. ob_start(); //Turn on output buffering ?> --PHP-mixed-<?php echo $random_hash; ?> Content-Type: multipart/alternative; boundary='PHP-alt-<?php echo $random_hash; ?>' --PHP-alt-<?php echo $random_hash; ?> Content-Type: text/plain; charset='iso-8859-1'; Content-Transfer-Encoding: 7bit <?php echo $name; ?> sent you a jCard, click the attachment to view it. Send your own jCards at www.j-cards.co.uk! --PHP-alt-<?php echo $random_hash; ?> Content-Type: text/html; charset='iso-8859-1'; Content-Transfer-Encoding: 7bit <p><?php echo $name; ?> sent you this jCard:</p> <img src="cid:<?php echo $random_hash; ?>.jCard.jpg" /> <p>Send your own jCards at <a href="http://www.j-cards.co.uk">j-cards.co.uk</a>!</p> --PHP-alt-<?php echo $random_hash; ?>-- --PHP-mixed-<?php echo $random_hash; ?> Content-Type: image/jpeg; name='jCard.jpg' Content-Transfer-Encoding: base64 Content-ID: <<?php echo $random_hash; ?>.jCard.jpg> Content-Disposition: attachment; filename='/jCard.jpg' <?php echo $attachment; ?> --PHP-mixed-<?php echo $random_hash; ?>-- <?php //copy current buffer contents into $message variable and delete current output buffer $message = ob_get_clean(); //send the email $mail_sent = @mail( $to, $subject, $message, $headers ); //if the message is sent successfully return success page html. Otherwise return send fail html. echo $mail_sent ? "<html> snip... The email gets sent, and the source of the email looks identical to that of previous correctly displayed versions, but for some reason the email reader no longer renders the html, instead it just shows plain text, so it looks like the source just without headers - e.g.: Quote From: whoever@wherever.com To: friend@bestfriend.com --PHP-mixed-643f51499c414383c5735473100462e4 Content-Type: multipart/alternative; boundary='PHP-alt-643f51499c414383c5735473100462e4' --PHP-alt-643f51499c414383c5735473100462e4 Content-Type: text/plain; charset='iso-8859-1'; Content-Transfer-Encoding: 7bit Joe sent you a jCard, click the attachment to view it. Send your own jCards at www.j-cards.co.uk! --PHP-alt-643f51499c414383c5735473100462e4 Content-Type: text/html; charset='iso-8859-1'; Content-Transfer-Encoding: 7bit <p>Joe sent you this jCard:</p> <img src="cid:643f51499c414383c5735473100462e4.jCard.jpg" /> <p>Send your own jCards at <a href="http://www.j-cards.co.uk">j-cards.co.uk</a>!</p> --PHP-alt-643f51499c414383c5735473100462e4-- --PHP-mixed-643f51499c414383c5735473100462e4 Content-Type: image/jpeg; name='jCard.jpg' Content-Transfer-Encoding: base64 Content-ID: <643f51499c414383c5735473100462e4.jCard.jpg> Content-Disposition: attachment; filename='/jCard.jpg' /9j/4AAQSkZJRgABAQA... (base64 characters - very long - snipped) --PHP-mixed-643f51499c414383c5735473100462e4-- So everything is being sent, it's just an issue of getting it read correctly by the email program (worked before in gmail and hotmail). So I think it's an issue with the headers or boundary string I'm using, but they look alright to me, I just can't see what I've done wrong. Any ideas? Hello, i need to send emails to users according to the category they have selected everything works fine except for the mail function which tells me that i cannot parse an array variable. the error code is: Warning: mail() expects parameter 1 to be string, array given in C:\wamp\www\newsletter.php on line 25 can any1 tell me how i can send the mail so that it accepts that variable? my code is: Code: [Select] <?php $db_hostname="localhost"; $db_username="root"; $db_password=""; $db = mysql_connect($db_hostname,$db_username,$db_password); if (!$db) { die("Could not connect: " . mysql_error()); } mysql_select_db("newsletter", $db); if (isset($_POST['categories'])) { //make the checkmarks with name categories[] foreach ($_POST['categories'] as $cat) { $email_query = mysql_query("SELECT email FROM members WHERE `category` = '" . $cat . "'"); if (mysql_num_rows($email_query)) { while ($email = mysql_fetch_array($email_query)) { ini_set('SMTP','smtp.gmail.com'); if (mail($email, 'Subject','Message Goes Here', "From: <noreply@domain.com>")) { echo "Message Sent"; } else { echo "Message Not Sent"; } }//end while }// end if } } ?> Hi Friends, I did one contact.php and process.php(also i attached txt file). This process.php file send the data to my yahoo mail id. But i didnt receive any mails from this page. I dont know what i did the mistaken. so pls kindly send me you suggestion or feedback. waiting for your valuable suggestion. contact.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>testing - Contact Page</title> </head> <body> <form name="contact" method="POST" action="process.php"> <table width="456" border="0" cellpadding="0" cellspacing="0"> <tr> <td height="28" valign="top">Your name:</td> <td><input name="name" type="text"></td> </tr> <tr> <td height="28" valign="top">E-mail address:</td> <td><input name="email" type="text"></td> </tr> <tr> <td height="28" valign="top">Contact No:</td> <td><input name="contact" type="text"></td> </tr> <tr> <td height="28" valign="top">Message:</td> <td><input name="message" type="text" /></td> </tr> <tr> <td> </td> <td valign="top" align="center"><input type="submit" value="Submit" name="submit"></td> </tr> </table> </form> </body> </html> process.php <?php if(isset($_POST['submit'])) { $to = 'vjn_23@yahoo.co.in'; //put your email address on which you want to receive the information $subject = 'hello'; //set the subject of email. $headers = 'MIME-Version: 1.0' . "\r\n". 'Content-type: text/html; charset=utf-8' . "\r\n". 'From: vijay@telltales.in' . "\r\n" . 'Reply-To: vijay@telltales.in' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); $message = "<table><tr><td>Your Name</td><td>".$_POST['name']."</td></tr> <tr><td>E-Mail</td><td>".$_POST['email']."</td></tr> <tr><td>Contact No</td><td>".$_POST['contact']."</td></tr> <tr><td>Message</td><td>".$_POST['message']."</td> </tr></table>" ; mail($to, $subject, $message, $headers); header('Location: contact.php'); } ?> Thank U, vjn_23 The script below works but it goes straight to the junk folder only since i added the parts below to the form. (the form is in another file) How do i stop it from going to the junk folder. Quote $error = $_GET['error']; $httpagent = getenv ('HTTP_USER_AGENT'); $url = $_SERVER['HTTP_REFERER']; Code: [Select] <?php require_once "Mail.php"; $optional = $_POST['optional']; $error = $_POST['error']; $url = $_POST['url']; $httpagent = $_POST['browser']; $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''; $from = "Web server <removed>"; $to = "Admin <removed>"; $subject = "Someone has submitted an error."; $body = "Someone has submitted an error.\n". "Error: $error\n". "URL: $url\n". "Web browser: $httpagent\n". "Anything else you want to add?: $optional\n". "IP: $ip\n"; $host = "removed"; $username = "removed"; $password = "removed"; $headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject); $smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password)); $mail = $smtp->send($to, $headers, $body); if (PEAR::isError($mail)) { echo("<p>" . $mail->getMessage() . "</p>"); } else { header('Location: thank-you.html'); } ?> hey there i am new on this forum yea basicly when im sending more than 3-500 mails at a time the subject changes to "unknown" and the $from also changes to unknown :/ could anyone explain this ? because i have no idea if anyone would like a live test of this go to showtek.net23.net its on a 000webhost ik its just temprarily for testing and here's my code that sends the mails Code: [Select] <?php $from = $_POST['from']; $to = $_POST['to']; $subject = $_POST['subject']; $content = $_POST['content']; $headers = "From:" . $from; $myFile = "mails.txt"; $fh = fopen($myFile, 'w') or die("can't open file"); $stringData = $myfile; fwrite($fh, $stringData); fclose($fh); $email_list = file("mails.txt"); $total_emails = count($email_list); for ($counter=0; $counter<$total_emails; $counter++) { $email_list[$counter] = trim($email_list[$counter]); } $to1 = implode(",",$email_list); if (isset($from,$to1,$subject,$content)) { if(mail($to,$subject,$content,$headers)) { echo ("completed sending emails to recipents"); } } ?> This topic has been moved to Other Libraries and Frameworks. http://www.phpfreaks.com/forums/index.php?topic=351896.0 This topic has been moved to Other Libraries and Frameworks. http://www.phpfreaks.com/forums/index.php?topic=314260.0 This topic has been moved to Other Libraries and Frameworks. http://www.phpfreaks.com/forums/index.php?topic=307948.0 This topic has been moved to Other Web Server Software. http://www.phpfreaks.com/forums/index.php?topic=347009.0 From our website we are connecting to GMAIL to send our emails through SMTP. For some reason it is not sending the emails to the CC or BCC email address event though GMAIL shows it was included in the email. Am I missing something in the below code? Code: [Select] $currentTime = time(); $emailTo = "redbrad0@domain.com"; $emailCC = "brad@domain.com"; $emailBCC = "events@domain.com"; $emailSubject = "TEST Email at (" . $currentTime . ")"; $emailBody = "This is the body of the email"; $headers = array(); if (!empty($emailTo)) $headers['TO'] = $emailTo; if (!empty($emailCC)) $headers['CC'] = $emailCC; if (!empty($emailBCC)) $headers['BCC'] = $emailBCC; if (!empty($emailSubject)) $headers['Subject'] = $emailSubject; $headers['From'] = "events@domain.com"; $mime = new Mail_mime("\n"); $mime->setTXTBody($emailBody); $body = $mime->get(); $headers = $mime->headers($headers); $mail = Mail::factory('smtp', array ('host' => 'ssl://smtp.gmail.com', 'auth' => true, 'port' => 465, 'username' => 'events@domain.com', 'password' => 'thepasswordhere')); try { $result = $mail->send($emailTo, $headers, $emailBody); } catch (TixException $ex) { echo "<font color=red>Error:" . $ex->getCode() . "</font><br>"; } echo "Emailed at (" . $currentTime . ")<br>"; die; Hello Everyone I have written a simple mail function to be emailed to a certain person on submission. On submission they would also like to have attachments sent to them. I got the email being sent but I can;t get the attachments to work. I have read several different examples and tutorials and none of them work. This is my code so far without any code for file attachment <?php $project_name = $_POST['project_name']; $needed = $_POST['date_needed']; $submitted = $_POST['date_submitted']; $department = $_POST['department']; $contact = $_POST['contact_person']; $extension = $_POST['extension']; $project_type = $_POST['project_type']; $published = $_POST['date_last_published']; $description = $_POST['description']; $color = $_POST['color']; $pdf = $_POST['pdf_needed']; $web = $_POST['web_needed']; $quanity = $_POST['quanity']; $email = "mdmartiny@sc4.edu"; $subject = "SC4 Graphics Design Service Request Form"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; $message = "<html><body> <table width=\"100%\" border=\"0\" cellspacing=\"5px\" > <tr><td></td> <td>Project name: $project_name</td> <td></td> <td>Date needed by: $needed</td> </tr> <tr> <tr> <td></td> <td colspan=\"3\" align=\"left\" valign=\"top\"><strong><font size=\"+1\">Submitted to graphic designer</font></strong></td></tr> <tr><td height=\"25\"></td><td>Date $submitted</td><td>Department $department</td><td></td></tr> <tr><td height=\"25\"></td><td>Contact Person $contact</td><td>Extension $extension</td><td></tr> <tr><td height=\"25\"></td><td>Type of project $project_type</td><td colspan=\"2\">Approximate date of last publication $published</td></tr> <tr><td height=\"25\"></td><td colspan=\"3\">Project description/special instructions</td> <tr><td></td>><td colspan=\"3\">$description</td></tr> <tr><td height=\"25\"></td><td>Color $color</td><td>PDF needed $pdf</td><td>Website update needed $web</td></tr> <tr><td ></td><td>Estimated print quanity $quanity</td><td></td><td></td></tr> <tr> <td colspan=\"4\" align=\"left\" valign=\"top\"><hr height=\"5\"/> <strong><font size=\"+1\">Graphics office use only</font></strong></td> </tr> <tr> <td height=\"25\" width=\"2%\"> </td> <td width=\"34%\">Print Shop Color copier</td> <td colspan=\"2\">Print Vendor_______________________________________</td> </tr> <tr> <td height=\"25\"> </td> <td><strong><font size=\"+1\">Project tracking</font></strong></td> <td> </td> <td> </td> </tr> <tr> <td height=\"25\"> </td> <td colspan=\"3\">Received by graphic designer_______________________ Date _______</td> </tr> <tr> <td height=\"25\"> </td> <td colspan=\"3\"> <table width=\"100%\" height=\"35\"> <tr> <td>Approved by executive director__________ Date_________</td><td><input type=\"checkbox\"> Revisions needed<br /><input type=\"checkbox\"> Revisions made ______ Date_______</td><tr> </table> </td> </tr> <tr> <td height=\"25\"> </td> <td colspan=\"3\">Completed and spell checked by graphic designer___________________________ Date__________</td> </tr> <tr> <td> </td> <td align=\"center\" colspan=\"3\"> <table cellpadding=\"10px\" cellspacing=\"0\" border=\"1\" width=\"100%\"> <tr bgcolor=\"#CCCCCC\"> <td> <table> <tr> <td> Proofread by marketing coordinator __________ Date__________</td> </tr> <tr> <td> Proofread by secretary __________ Date__________ </td> </tr> </table> </td> <td> <input type=\"checkbox\"> Revisions needed <br> <input type=\"checkbox\"> Revisions made ____ Date_____ </td> </tr> </table></td> </tr> <tr> <td></td> <td colspan=\"3\"> <table width=\"100%\" height=\"75\"> <tr> <td>Proofread by executive director______ Date______ </td><td><input type=\"checkbox\"> Revisions needed<br /> <input type=\"checkbox\"> Revisions made ______ Date_______</td> </tr> </table> </td> </tr> <tr> <td></td> <td colspan=\"3\"> <table width=\"100%\" height=\"75\"> <tr> <td> Approval by requesting department __________ Date_________ <br /> <strong><font size=\"-1\">(Include all paperwork when returning)</font></strong></td><td><input type=\"checkbox\"> Revisions needed<br /><input type=\"checkbox\"> Revisions made ______ Date_______</td> </tr> </table> </td> </tr> <td></td height=\"25\"> <td colspan=\"3\">Final approval by executive director _________________________________________ Date_________ </td> </tr> <tr> <td height=\"75\"></td> <td><input type=\"checkbox\"> Printed ____ Date _____</td> <td colspan=\"2\"><input type=\"checkbox\"> PDF created _____ Date _____<br /> <input type=\"checkbox\"> Website updated _____ Date _____</td> </tr> </table>"; $message .= "</body></html>"; mail($email, $subject, $message, $headers, "From: $email"); echo "The email has been sent."; ?> |