473,385 Members | 2,162 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Sending E-mail using PHPMailer()

KeredDrahcir
426 256MB
I'm trying to send an E-mail using PHPMailer and although everything look okay, it's not coming through. Can anyone help?
I'm posting my information from a form.
Expand|Select|Wrap|Line Numbers
  1.     require_once ("class.phpmailer.php");
  2.     $contact_id    = $_REQUEST['contact_id'];
  3.     $to_email = $_REQUEST['to_email'];
  4.     $id    = $_SESSION['id'];
  5.     $subject = $_REQUEST['subject'];
  6.     $body = $_REQUEST['body'];
  7.     $send_as_html = ($_REQUEST['send_as_html']==''?false:true);
  8.  
  9.     $mail_from_name = $_SESSION['name'];
  10.     $mail_from_email = $_SESSION['login'];
  11.  
  12.     $sql = "SELECT * FROM contact WHERE contact_id = $contact_id";
  13.     $result = mysql_query($sql,$db);
  14.  
  15.     $first_name    = mysql_result($result,0,'first_name');
  16.     $last_name     = mysql_result($result,0,'last_name');
  17.     $email = mysql_result($result,0,'email');
Then I try to send the E-mail
Expand|Select|Wrap|Line Numbers
  1.  
  2. <table border="1" cellpadding="3" cellspacing="0" bordercolor="#CCCCCC">
  3. <?
  4.             $mail = new PHPMailer();
  5.             $mail->IsSMTP(true);
  6.             $mail->Host = 'localhost';
  7.             $mail->From = $mail_from_email;
  8.             $mail->FromName = $mail_from_name;
  9.             $mail->AddAddress($email);
  10.             $mail->AddBCC('myemail');
  11.             $mail->IsHTML($send_as_html);
  12.             $mail->Subject = $subject;
  13.             $mail->Body    = stripslashes($body);
  14.  
  15.             if($mail->Send())
  16.             {
  17. ?>
  18.               <tr>
  19.                 <td><?=$email;?></td>
  20.                 <td>Sent</td>
  21.               </tr>
  22. <?
  23.             }
  24.             else
  25.             {
  26. ?>
  27.               <tr>
  28.                 <td><?=$to_email?></td>
  29.                 <td>Failed [<?=$mail->ErrorInfo?>]</td>
  30.               </tr>
  31. <?
  32.             }
  33.             unset($mail);
  34. ?>
  35.           </table>
Is tells me the E-mail was sent, but doesn't come through. Any ideas?
Jun 8 '10 #1
4 1846
KeredDrahcir
426 256MB
Can anyone help please?
Jun 11 '10 #2
KeredDrahcir
426 256MB
can anyone suggest anything I could try if you need more information?
Jul 9 '10 #3
TheServant
1,168 Expert 1GB
Print all of your variables that are sent to the mail object and check they are what you expect. I will have a better look tomorrow... Must go to bed!
Jul 9 '10 #4
KeredDrahcir
426 256MB
Thanks. I'll try that when I'm back on Thursday.
Jul 9 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Robert Pettersson | last post by:
Hi, I have built an webapp in C# that uses SMTPMail to send mail to users. When I installed it on the prodserver everything worked fine for me, but the users can not send mail. They get Access...
3
by: sagar | last post by:
i tried to send a email through asp using codes given on the book. but there is an error saying: ActiveX component can't create object: 'CDONTS.NewMail' what's that error for.,,and how can i...
3
by: Srinivas | last post by:
Hi, I am using ASP.NET SmtpMail to send email using the following code public void SendEmail(string From, string To, string Subject, StringBuilder Message, string Attachment, string...
6
by: lalit26011983 | last post by:
Can any1 help me... How to send emails using asp.net.. I m using windows 2000 server and visual studio 2003(.net framework 1.1) I m not getting any error while i m sending email using...
0
by: Sister Ray | last post by:
I'm trying to create a simple form that sends an email using my company's exchange server. I'm using the System.Net.Mail Namespace of the .net framework 2.0. I've googled everywhere and i think my...
2
by: prasenjit2007 | last post by:
Hello, can u help me sending Email with attachments using the Class phpMailer. On the website I have a link to an html form in which I input the parameters with the names 1)from(textbox name)...
2
by: haytham2008 | last post by:
hi every body i have this problem while i trying to send email using php i found a function <?php mail(); ?> but does not work with me since i use smtp server with user name and password
3
by: shansivamani | last post by:
using SMTP to send email. is there any settings need to be configured apart from Host name and Port, while sending emails using SMTPClient in .Net? when i try to send mail to ids which has only...
0
by: trivedimca2005 | last post by:
I am using below code for sending Email using .net. Its not working on client machine. My server IP is:- 192.168.10.10 and also uses proxy and user-name and password for proxy settings are...
6
by: Chocolade | last post by:
Hi, Im using System.Net.Mail to send email in my application it was working great without any problems untill this morning after like 20-30 tries it was sending the email ok then suddenly this...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.