473,785 Members | 2,698 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sending E-mail using PHPMailer()

KeredDrahcir
426 Contributor
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 1864
KeredDrahcir
426 Contributor
Can anyone help please?
Jun 11 '10 #2
KeredDrahcir
426 Contributor
can anyone suggest anything I could try if you need more information?
Jul 9 '10 #3
TheServant
1,168 Recognized Expert Top Contributor
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 Contributor
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
2908
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 denied. If I add them to the administrator group of the server everything works fine. I have set <identity impersonate="true"/>
3
1634
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 correct it.
3
1603
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 mailFormat) { MailMessage mailMessage = new MailMessage (); mailMessage.From = From; mailMessage.To = To;
6
2358
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 asp.net(With SMTP) but the receiver is not getting mail... It's very URGENT.... I already set connection(127.0.0.1) and Relay(127.0.0.1) using Inetmgr(Default SMTP Virtual Server)...... Plz help me.... Thanks....
0
2778
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 code is ok, however i keep getting a "A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond" error every time. Any...
2
4560
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)To 3) Subject 4) Message5) File input(name abc) - to be sent as an attachment. This form calls the Class PhpMailer through another form with the following code to send the mail. <?php ini_set("include_path",...
2
2186
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
1791
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 one dot in the domain name (eg : test@abc.com) there are no issues. but when the mail ids are like (test@abc.co.in or test@abc.rr.com) the mail is not getting received by those ids. also, there are no exceptions occured when i debugged it.
0
1329
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 user-name:- user and password:-user. Where I have to specify this proxy settings in my below code. Dim message As New MailMessage() message.From = New MailAddress(txtFrom.Text.Trim()) message.To.Add(New...
6
9207
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 morning i got an exception and i cant figure out what/where the problem is and how to fix it. The problem say i have some invalid char: invalid character was found in the mail header: 'י'. Now this char 'י' is an hebrew letter. But i searched...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10327
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10092
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8973
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6740
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.