Jump to content

Search the Community

Showing results for tags 'phpmailer'.

  • 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 (PhpStorm, VS Code, 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 16 results

  1. I am just learning how to use PHPMailer. I have not touched anything on any of the PHPMailer files. I am using php 5.2.17 I am surprised to get this error: Parse error: syntax error, unexpected T_FUNCTION in /home/content/33/3333333/html/folder/folder2/PHPMailer/class.phpmailer.php on line 3042 I assumed that this would be something common and I would find another person who had the same issue. Only I do not see anyone with the same error and line as this. I could post my code, but the error comes before any of my code is run. Meaning the php file starts with: date_default_timezone_set('America/Los_Angeles'); require 'PHPMailer/PHPMailerAutoload.php'; The error is found before any of my code is run.
  2. Will someone, who doesn't mind helping an old man understand some things, explain how to use PHPMailer? You see, I downloaded a registration form that sends a verification e-mail. I'm testing all of this on my local machine (Linux). The mail, of course, fails to be delivered. So I surf around and see where phpmailer can help me with this. So I downloaded phpmailer-master. But I have absoultely no idea where to put what so I'll have e-mail capability from localhost. If you can tell me what goes where, I promise to name my next child after ya I just need some guidance on this one. It has me totally confused! Landslyde PS: Happy 2015 to all!
  3. I would like to send an email when % is >than 50%, if so get fields from Txt fiel and fields from DB and send an email to the address in the txt file. <html> <head><title>Email Alert</title></head> <body> <?php require 'PHPMailerAutoload.php'; $mail = new PHPMailer; //$mail->SMTPDebug = 3; // Enable verbose debug output mysql_connect("ip","user","pass") or die(mysql_error()); //mysql_select_db("DB") or die(mysql_error()); //$sql = "SELECT * from pool"; $sql = mysql_db_query ("demo", "select * from pool "); while ($row = mysql_fetch_assoc($sql)) { $sql = "SELECT '%' FROM pool Where >= 50 "; { //echo $row->number; $percent = $row['%'] ; $pool2 = $row['pool']; $balance = $row['balance']; /////////////////////////// //data from file ////////// ////////////////////////// $file = fopen('EmailAndPool2.csv', 'r'); $fields = array(); if ($file) { while (($data = fgetcsv($file)) !== false) { if(empty($fields)) { $fields = $data; continue; } $row = array_combine($fields, $data); // Format output conveniently with sprintf $output = sprintf("%s Pool %s email.\n", $row['pool'], $row['email']); echo $output; } fclose($file); $pool1 = $row['pool']; //while ($pool2 == $pool1 and $percent > "50") $pool2 =$row['pool2']; $mail = new PHPMailer; $mail->isSMTP(); // Set mailer to use SMTP $mail->Host = 'xxxxxxxxx; // Specify main and backup SMTP servers $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = 'xxxxxxxxxxxxxxxxx'; // SMTP username $mail->Password = 'xxxxxxxxxxxxxxxx; // SMTP password $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted $mail->Port = 587; // TCP port to connect to $mail->FromName = 'Support'; $mail->addAddress ($row['email']); //$mail->addAddress = $members; //$mail->addCC('xxxxxxxxxxx'); //$mail->addCC('xxxxxxxxxxxxxxxx'); $mail->WordWrap = 50; // Set word wrap to 50 characters $mail->isHTML(true); $mail->Subject = 'test'; $mail->Body = 'test '; $email_from = 'xxxxxxxxxxxx'; } if(!$mail->send()) { echo 'Message could not be sent.'; echo 'Mailer Error: ' . $mail->ErrorInfo; } else { echo 'Message has been sent'; } } } ?> </body> </html> Thank you
  4. Hello, I am sending an email via phpmailer to a large group of recipients. I bcc'd the entire group which of course failed after the max limit was reached so I thought what about sending in chunks.... Im just trying to figure out how to loop through the groups of bcc's basically Im thinking something like this... $mail = new PHPMailer(true); $mail->IsSMTP(); //setup from, replyto etc here... //email query here to get emails in array $bccz.. //chunk results $newArray = array_chunk($bccz, 50, false); // Now process array_chunk() $i = 0; foreach ($newArray as $inner_array) { $i++; while (list($key, $value) = each($inner_array)) { addBCC($value['email']); }$subject = '=?UTF-8?B?'.base64_encode($cobig).'?='; $mail->Subject = $subject; $mail->IsHTML(true); $mail->Body = $ermail; $mail->Send(); } $mail->clearBcc(); } Just wondering if someone can tell me if this basic logic is right?
  5. I'm new to PHP and working on a mailform with phpmailer with attachment. Everything works fine but the received mail keeps having my Gmail address in the from header. The AddReplyTo address works fine but I don't want to show the gmail address. This is what my code looks like: require('C:\xampp\htdocs\PHPMailer\class.phpmailer.php'); $mail = new PHPMailer(); // create a new object $mail->IsSMTP(); // enable SMTP $mail->SMTPDebug = 2; // debugging: 1 = errors and messages, 2 = messages only $mail->SMTPAuth = true; // authentication enabled $mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail $mail->Host = 'smtp.gmail.com'; $mail->Port = 465; $mail->Username = 'myaccount@gmail.com'; $mail->Password = 'mypassword'; $mail->SetFrom('e-mail@address.com', 'email@address.com'); $mail->AddReplyTo('e-mail@address.com', 'e-mail@address.com'); $mail->AddAddress("myaccount@gmail.com", "MyAccount"); $mail->Subject = "TestMail"; $mail->Body = "This is the message body"; $mail->AddAttachment("test.txt", "test.txt"); // optional name if(!$mail->Send()) { echo "Error"; exit; } else { echo "OK"; } I only want to use the gmail smtp but want to show another e-mail address (e-mail@address.com in thie example) in the header. But it keeps showing myaccount@gmail.com. Also in the class.phpmailer.php I've configurated the $From, $FromName and $Sender as e-mail@address.com but this doesn't work. Can somebody help me with this?
  6. Due to unexpected server crash we had to migrate a site that worked smoothly on Fedora+PHP4 to a new environment with PHP5. Frontend and most functions on our customcoded front+backend simple ecomm site work well, except for two issues: in backend, probarly related to phpmailer and session management. Instead of posting questions on forum we would prefer to hire a realiable coder to review the code and fix whatever is needed. Please contact us on email mvm at 247365.info for further details and your requirements.
  7. I want to create a form where you can upload a file and that can be sent as an attachment of an e-mail. I've have two alternatives, one using PHPMailer, and the other not using PHPMailer. My problems are as listed: 1. When using PHPMailer, I'm getting the `SMTP:Could Not Connect()` error even though all the SMTP credentials are right. 2. When not using PHPMailer, I'm getting an error in the `fopen()` function. Even then, I'm receiving the file, but its empty. I'm really a starter with PHP, so need help on this one. I'm posting both the codes here. 1. Using PHPMailer: <?php require('PHPMailer/class.phpmailer.php'); if(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED //$email_to = "email"; //$email_subject = "Request for Portfolio check up from ".$first_name." ".$last_name; $title = array('Title', 'Mr.', 'Ms.', 'Mrs.'); $selected_key = $_POST['title']; $selected_val = $title[$_POST['title']]; $first_name = $_POST['first_name']; // required $last_name = $_POST['last_name']; // required $email_from = $_POST['email']; // required $telephone = $_POST['telephone']; // not required $comments = $_POST['comments']; // required if(($selected_key==0)) echo "<script> alert('Please enter your title')</script>"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message = ""; $email_message .="Title: ".$selected_val."\n"; $email_message .= "First Name: ".clean_string($first_name)."\n"; $email_message .= "Last Name: ".clean_string($last_name)."\n"; $email_message .= "Email: ".clean_string($email_from)."\n"; $email_message .= "Telephone: ".clean_string($telephone)."\n"; $email_message .= "Comments: ".clean_string($comments)."\n"; $allowedExts = array("doc", "docx", "xls", "xlsx", "pdf"); $temp = explode(".", $_FILES["file"]["name"]); $extension = end($temp); if ((($_FILES["file"]["type"] == "application/pdf") || ($_FILES["file"]["type"] == "application/msword") || ($_FILES["file"]["type"] == "application/excel") || ($_FILES["file"]["type"] == "application/vnd.ms-excel") || ($_FILES["file"]["type"] == "application/x-excel") || ($_FILES["file"]["type"] == "application/x-msexcel") || ($_FILES["file"]["type"] == "application/vnd.openxmlformats-officedocument.wordprocessingml.document") || ($_FILES["file"]["type"] == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")) && in_array($extension, $allowedExts)) { if ($_FILES["file"]["error"] > 0) { echo "<script>alert('Error: " . $_FILES["file"]["error"] ."')</script>"; } else { if(move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"])) $file=fopen("upload/".$_FILES["file"]["name"], 'r'); } } else { echo "<script>alert('Invalid file')</script>"; } // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); //Create a new PHPMailer instance $mail = new PHPMailer(); //Tell PHPMailer to use SMTP $mail->IsSMTP(); //Enable SMTP debugging // 0 = off (for production use) // 1 = client messages // 2 = client and server messages $mail->SMTPDebug = 2; //Ask for HTML-friendly debug output $mail->Debugoutput = 'html'; //Set the hostname of the mail server $mail->Host = "hostname"; //Set the SMTP port number - likely to be 25, 465 or 587 $mail->Port = 465; //Whether to use SMTP authentication $mail->SMTPAuth = true; //Username to use for SMTP authentication $mail->Username = "email"; //Password to use for SMTP authentication $mail->Password = "password"; //Set who the message is to be sent from $mail->SetFrom($email_from, 'First Last'); //Set an alternative reply-to address //$mail->AddReplyTo('replyto@example.com','First Last'); //Set who the message is to be sent to $mail->AddAddress('email', 'name'); //Set the subject line $mail->Subject = 'Request for Profile Check up'; //Read an HTML message body from an external file, convert referenced images to embedded, convert HTML into a basic plain-text alternative body $mail->MsgHTML($email_message); //Replace the plain text body with one created manually $mail->AltBody = 'This is a plain-text message body'; //Attach an image file $mail->AddAttachment($file); //Send the message, check for errors if(!$mail->Send()) { echo "<script>alert('Mailer Error: " . $mail->ErrorInfo."')</script>"; } else { echo "<script>alert('Your request has been submitted. We will contact you soon.')</script>"; } } ?> 2. No PHPMailer: <?php $title = array('Title', 'Mr.', 'Ms.', 'Mrs.'); $selected_key = $_POST['title']; $selected_val = $title[$_POST['title']]; $first_name = $_POST['first_name']; // required $last_name = $_POST['last_name']; // required $email_from = $_POST['email']; // required $telephone = $_POST['telephone']; // not required $comments = $_POST['comments']; // required if(($selected_key==0)) echo "<script> alert('Please enter your title')</script>"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message = ""; $email_message .="Title: ".$selected_val."\n"; $email_message .= "First Name: ".clean_string($first_name)."\n"; $email_message .= "Last Name: ".clean_string($last_name)."\n"; $email_message .= "Email: ".clean_string($email_from)."\n"; $email_message .= "Telephone: ".clean_string($telephone)."\n"; $email_message .= "Comments: ".clean_string($comments)."\n"; $email_to = "email"; // The email you are sending to (example) //$email_from = "sendfrom@email.com"; // The email you are sending from (example) $email_subject = "subject line"; // The Subject of the email //$email_txt = "text body of message"; // Message that the email has in it $destination=$_FILES["file"]["name"]; move_uploaded_file($_FILES["file"]["name"], $destination); $fileatt = fopen($_FILES['file']['name'],'r'); // Path to the file (example) $fileatt_type = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; // File Type $fileatt_name = "Details.docx"; // Filename that will be used for the file as the attachment $file = fopen($fileatt,'r'); $data = fread($file,filesize($fileatt)); fclose($file); $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; $headers="From: $email_from"; // Who the email is from (example) $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; $email_message .= "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type:text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $email_txt; $email_message .= "\n\n"; $data = chunk_split(base64_encode($data)); $email_message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" . " name=\"{$fileatt_name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" . "--{$mime_boundary}--\n"; mail($email_to,$email_subject,$email_message,$headers); ?> And the form, with corresponding action: <form name="contactform" method="post" action="send2.php" enctype="multipart/form-data"> <table width="100%" border="0" align="center"> <tr> <td valign="middle" id="ta"> <label for="title">Title *</label> </td> <td valign="middle" id="ta"> <select name="title"> <option value="0">Title</option> <option value="1">Mr.</option> <option value="2">Ms.</option> <option value="3">Mrs.</option> </select></td></tr><tr><td id="ta"> <label for="first_name">First Name *</label> </td> <td valign="middle" id="ta"> <input type="text" name="first_name" maxlength="50" size="30" required="required"> </td> </tr> <tr> <td valign="middle" id="ta"> <label for="last_name">Last Name *</label> </td> <td valign="middle" id="ta"> <input type="text" name="last_name" maxlength="50" size="30" required="required"> </td> </tr> <tr> <td valign="middle" id="ta"> <label for="email">Email Address *</label> </td> <td valign="middle" id="ta"> <input type="text" name="email" maxlength="80" size="30" required="required"> </td> </tr> <tr> <td valign="middle" id="ta"> <label for="telephone">Telephone Number *</label> </td> <td valign="middle" id="ta"> <input type="text" name="telephone" maxlength="30" size="30" required="required"> </td> </tr> <tr> <td valign="middle" id="ta"> <label for="comments">Details</label> </td> <td valign="middle" id="ta"> <textarea name="comments" maxlength="100000" cols="25" rows="6"></textarea> </td> </tr> <tr> <td valign="middle" id="ta"> <label for="file">Or upload a file (only word, excel or pdf)</label> </td> <td valign="middle" id="ta"> <input type="file" name="file"> </td> </tr> <tr> <td colspan="2" style="text-align:center" id="ta"> <input type="submit" value="Submit"> </td> </tr> </table> </form> For reference, you may go to http://rsadvisories.com
  8. Hello How can I add a specific font and fontsize to my mail body ? require("class.phpmailer.php"); $mail = new PHPMailer(); $mail->IsSMTP(); // Laat PHPMailer gebruik maken van een smtp server. $mail->Host = "smtp.mijnhostingpartner.nl"; // SMTP server van Mijn Hosting Partner $mail->SMTPAuth = true; $mail->Username = 'webmaster@blackfeet.be'; // Een geldig emailadres wat aangemaakt is bij Mijn Hosting Partner $mail->Password = 'yr2805'; // Het wachtwoord wat bij het emailadres hoort $mail->FromName=$_POST['NAAM']; $mail->Sender=$_POST['EMAIL']; $mail->AddAddress("webmaster@blackfeet.be"); $mail->Subject = $subject; $mail->Body = $text; $mail->IsHTML(true); //Opmaak van de email is in HTML if(!$mail->Send()) { echo "Error sending: " . $mail->ErrorInfo;; } echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">'; ?>
  9. This mailer works with go daddy but I cant get it too work with a home server. It will send the mail and shows up in the inbox but not the content. I think it has to do with using $body tag but I am not sure any suggestions? <?php // PHPmailer settings $mail = new PHPMailer(); // create a new object $mail->Issmtp(); // enable SMTP $mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only $mail->SMTPAuth = true; // authentication enabled $mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail $mail->Host = 'smtp.gmail.com'; $mail->Port = 465; $mail->Username = "email"; // SMTP username $mail->Password = "password"; // SMTP password $mail->From = $email; $mail->FromName = $contact_name; $mail->SetFrom($email, $contact_name); $mail->AddAddress('email'); $mail->Priority = 1; $mail->WordWrap = 50; // set word wrap $mail->IsHTML(true); // send as HTML $mail->Subject = "Gray Gables maintenance request"; $mail->Body = $body; $mail->AltBody = "This is the text-only body"; // gets info from form $name = $_POST['name'] ; $email = $_POST['email'] ; $phone = $_POST['phone'] ; $message = $_POST['message'] ; $ip = $_SERVER['REMOTE_ADDR']; // defines how message looks in email $mail->Body=" Name: $name<br> Telephone: $phone<br> Email: $email<br> IP address: $ip <br> -------------------<br> Message:<br> $message"; // looks good in your inbox $mail->From = "$email"; $mail->FromName = "$name"; $mail->AddReplyTo("$email","$name"); // gives success or error if(!$mail->Send()) { echo 'Message could not be sent.'; echo 'Mailer Error: ' . $mail->ErrorInfo; exit; } echo ' <meta http-equiv="refresh" content="3;url=http/"> <center><font size="5px"> Message has been sent!!<br> you will be redirected to our home page in 3 seconds...<br> <a href="http">click here</a> to return now. </font> </center> '; ?> <?php echo ' Client IP: '; if ( isset($_SERVER["REMOTE_ADDR"]) ) { echo '' . $_SERVER["REMOTE_ADDR"] . ' '; } else if ( isset($_SERVER["HTTP_X_FORWARDED_FOR"]) ) { echo '' . $_SERVER["HTTP_X_FORWARDED_FOR"] . ' '; } else if ( isset($_SERVER["HTTP_CLIENT_IP"]) ) { echo '' . $_SERVER["HTTP_CLIENT_IP"] . ' '; } ?>
  10. Hello, I am using the latest version of PHPMailer to try and send mails. The SMTP server is configured to use the Gmail SMTP. Now the problem is that when I am sending mails to a person with a Gmail account there seems to be no problem but when I am sending my mail to someone with a non Gmail account for example Yahoo. The mail never reaches(I have checked the SPAM folder). My PHP Mailer setup is as follows-: <?php require_once('mailer/class.phpmailer.php');//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded $mail = new PHPMailer(); $body = "<html><head></head><body><strong>This is a System generated message. PLEASE DO NOT REPLY TO THIS MAIL.</strong><br />Click on the following link to activate your account-:<br /><a href='http://www.google.co.in'>Click Here !! </a><br />END OF MESSAGE.</body></html>"; $body = eregi_replace("[\]",'',$body); $mail->IsSMTP(); // telling the class to use SMTP$mail->Host = "smtp.gmail.com"; // SMTP server$mail->SMTPDebug = 2; // enables SMTP debug information (for testing) // 1 = errors and messages // 2 = messages only$mail->SMTPAuth = true; // enable SMTP authentication $mail->SMTPSecure = "tls"; // sets the prefix to the servier$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server$mail->Port = 587; // set the SMTP port for the GMAIL server $mail->Username = "foobar@gmail.com"; // GMAIL username $mail->Password = "foobar"; // GMAIL password $mail->SetFrom("foobar@gmail.com", "foo"); $mail->AddReplyTo("foobar@gmail.com", "foo"); $mail->Subject = "foo bar"; $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test $mail->MsgHTML($body); $address = $_GET['email']; $mail->AddAddress($address); if(!$mail->Send()) { echo "Mailer Error: " . $mail->ErrorInfo;} else { } ?> <html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>domail</title></head> < body></body></html> My Questions are as follows-: Do I have to reconfigure my SMTP every time I send my mail to a different account ? For example if I have to send it to a Yahoo account do I have to use the Yahoo SMTP or when I send my mail to a Rediff account do I have to use the Rediff SMTP ??PHPMailer doesn't report any errors, it just says that it sent the message but the message never arrives. Can't I just use one SMTP and send mails to any account ? I am using WAMP server on my PC to run my Apache Web Server. Will this create problems in sending mails even if PHPMailer is configured correctly ? Is it necessary to add a name with the receiver address in the line-: $mail->AddAddress($address); Do I have to write it like this $mail->AddAddress($address,"Receiver Name"); Since my mail will be sent to anyone signing up specifying the correct receiver name every time will be a little difficult to do. I am getting an error on the line-: $body = eregi_replace("[\]",'',$body); The problem is that the function eregi_replace() has become deprecated. According to the php.net documentation I have to use preg_replace() with the " i " switch. But since I am beginner to PHP and regular expression I can't figure out how to do that. Can someone give the code which accomplishes the same task as the line above using preg_replace. Thank You.
  11. Hi I've wrote a small bit of code which basiclly sends out an email with an jpg attached, nothing fancy. The code works fine when not included within a function. However, as soon as it's included within a function the email still sends.. however no jpg is attached. The code below is it within a function. Any ideas why is it not adding the attachment when inside a function? function resendOrder() { require_once('OrderMailer/class.phpmailer.php');// need this to send email $mail = new PHPMailer(); // HTML body $body = "Testing"; // And the absolute required configurations for sending HTML with attachement $mail->From = "mark@******.co.uk"; $mail->AddAddress("mark@******.co.uk", "My-webpage Website"); $mail->Subject = "test for phpmailer-3"; $mail->MsgHTML($body); $mail->AddAttachment("ploxy.jpg"); if(!$mail->Send()) { echo "There was an error sending the message"; exit; } else{ echo "Message was sent successfully"; } }
  12. hi, is there a way to show the e.g "via blahblah.com" in the recipients email header ? because if I do e.g "From: sender fullname <sender@email.com> via email.com" and send the mail..what am seeing is sender fullname<sender@email.com> via email.com subject when opening the inbox, it is appended in the sender's name what i want to see when the recipient opens the inbox is the Full Name subject then when he/she clicks that row of email from the inbox, he/she will see the Full Name <sender@email.com> via email.com at the email header..is that possible in the built-in php mail function or the phpmailer library ? coz i have browsed the manual, i can't see a solution for this
  13. I am a newbie with php. I am trying to have a form that will have some basic field and 4 upload fields that allow visitor to send files to me. I know how to do the basic validation for text, email, etc with input field but have been trying to find a solution for uploading multiple files validate that they are image or pdf file attach to the email and send with phpmailer to me. I have tried to use the codes from tutorial, other site questions, etc but can't figure out how it all works. Can someone please provide a sample code to help me? thanks.
  14. When i run the following code,it will shows the error... Mail error: The following From address failed: uppalakishore@hotmail.com : Called Mail() without being connected <?php require_once("./Includes/PHPMailer/class.phpmailer.php"); // require_once("./Includes/PHPMailer/class.smtp.php"); define('GUSER', 'myname@gmail.com'); // GMail username define('GPWD', 'mypassword'); // GMail password function smtpmailer($to, $from, $from_name, $subject, $body) { global $error; $mail = new PHPMailer(); // create a new object $mail->IsSMTP(); // enable SMTP $mail->SMTPDebug = 0; // debugging: 1 = errors and messages, 2 = messages only $mail->SMTPAuth = true; // authentication enabled $mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail $mail->Host = 'smtp.gmail.com'; $mail->Port = 465; $mail->Username = GUSER; $mail->Password = GPWD; $mail->SetFrom($from, $from_name); $mail->Subject = $subject; $mail->Body = $body; $mail->AddAddress($to); if(!$mail->Send()) { $error = 'Mail error: '.$mail->ErrorInfo; return false; } else { $error = 'Message sent!'; return true; } } if (smtpmailer('myname@gmail.com', 'uppalakishore@hotmail.com', 'PHotoGallery', 'test mail message', 'Hello World!')) { // do something } if (!empty($error)) echo $error; ?> Thanks in Advance For Watching...
  15. Hi guys Hoping you can help me with this. I'm very much a front end person, I know HTML, CSS and some JS but when it comes to PHP and very much a newbie. I'm using this code to process a straight forward contact form. I'm using the PHP Mailer as I need to use an external smtp server and the company I use for this provided some basic code. Its working but I'm getting a error flash up before I see the success page that says "Undefined variable: message in send.php on line 25. Why is this happening and how do I fix it? Thanks guys. my code <?php require("PHPMailerAutoload.php"); // path to the PHPMailer class. $after = "/contact/thanks.php"; $oops = "/contact/error.php"; $mail = new PHPMailer(); $mail->IsSMTP(); $mail->Mailer = "smtp"; $mail->Host = "smtpcorp.com"; $mail->Port = "2525"; $mail->SMTPAuth = true; $mail->Username = "name@hotmail.com"; $mail->Password = "xxx"; $mail->From = "name@hotmail.com"; $mail->FromName = "Richard Dale"; $mail->AddAddress("name@hotmail.com", "Rachel Recipient"); $mail->AddReplyTo("name@hotmail.com", "Sender's Name"); $mail->Subject = "Contact enquiry from the website"; $message .= "How can we help: {$_POST['help']} \n\n"; $message .= "Name: {$_POST['name']} \n\n"; $message .= "Email: {$_POST['email']} \n\n"; $message .= "Telephone: {$_POST['tel']} \n\n"; $message .= "Message: {$_POST['message']} \n\n"; $message .= "Address: {$_POST['address']} \n\n"; $mail->Body = $message; $mail->WordWrap = 50; if(!$mail->Send()) { echo "<meta HTTP-EQUIV=\"REFRESH\" content=\"0; url=$oops\">"; } else { echo "<meta HTTP-EQUIV=\"REFRESH\" content=\"0; url=$after\">"; } ?>
  16. I am attempting to create a php AJAX contact form , however the email never seems to arrive in my outlook. /* Jquery Validation using jqBootstrapValidation example is taken from jqBootstrapValidation docs */ $(function() { $("input,textarea").jqBootstrapValidation( { preventSubmit: true, submitError: function($form, event, errors) { // something to have when submit produces an error ? // Not decided if I need it yet }, submitSuccess: function($form, event) { event.preventDefault(); // prevent default submit behaviour // get values from FORM var name = $("input#name").val(); var email = $("input#email").val(); var phone = $("input#phone").val(); var message = $("textarea#message").val(); var firstName = name; // For Success/Failure Message // Check for white space in name for Success/Fail message if (firstName.indexOf(' ') >= 0) { firstName = name.split(' ').slice(0, -1).join(' '); } $.ajax({ url: "./bin/contact_me.php", type: "POST", data: {name: name,phone:phone, email: email, message: message}, cache: false, success: function() { // Success message $('#success').html("<div class='alert alert-success'>"); $('#success > .alert-success').html("<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×") .append( "</button>"); $('#success > .alert-success') .append("<strong>Your message has been sent. </strong>"); $('#success > .alert-success') .append('</div>'); //clear all fields $('#contactForm').trigger("reset"); }, error: function() { // Fail message $('#success').html("<div class='alert alert-danger'>"); $('#success > .alert-danger').html("<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×") .append( "</button>"); $('#success > .alert-danger').append("<strong>Sorry "+firstName+" it seems that my mail server is not responding...</strong> Could you please email me directly ? Sorry for the inconvenience!"); $('#success > .alert-danger').append('</div>'); //clear all fields $('#contactForm').trigger("reset"); }, }) }, filter: function() { return $(this).is(":visible"); }, }); $("a[data-toggle=\"tab\"]").click(function(e) { e.preventDefault(); $(this).tab("show"); }); }); /*When clicking on Full hide fail/success boxes */ $('#name').focus(function() { $('#success').html(''); }); <?php require("../lib/phpmailer/PHPMailerAutoload.php"); if(empty($_POST['name']) || empty($_POST['email']) || empty($_POST['phone']) || empty($_POST['message']) || !filter_var($_POST['email'],FILTER_VALIDATE_EMAIL)) { echo "No arguments Provided!"; return false; } $m = new PHPMailer(); $m->IsSMTP(); $m->SMTPAuth = true; $m->SMTPDebug = 2; $m->Host = "smtp-mail.outlook.com"; $m->Username = ""; $m->Password = ""; $m->SMTPSecure = 'tls'; $m->Port = 587; $m->addAddress('EXAMPLE@outlook.com', $name); $name = $_POST['name']; $email_address = $_POST['email']; $phone = $_POST['phone']; $message = $_POST['message']; $m->Subject = "Contact Form has been submitted"; $m->Body = "You have received a new message. <br><br>". " Here are the details:<br> Name: $name <br> Phone Number: $phone <br>". "Email: $email_address<br> Message <br> $message"; if(!$m->Send()) { echo "Mailer Error: " . $m->ErrorInfo; exit; } ?>
×
×
  • 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.