473,782 Members | 2,494 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PEAR: Using PEAR_Error in Mail::send()

I'm trying to send e-mail using PEAR's Mail class--for testing purposes
actually, I've never had any problem with conventional mail(). This is
what my code looks like:

$mail_object=&M ail::factory('s endmail', $params);
if($mail_object->send($to, $headers, $body)){
header('Locatio n: '.$url_ok);
}else{
header('Locatio n: '.$url_ko);
}

This works (i.e., sends mail) but I know it isn't fine. My code never
shows any error, even after removing sendmail link... The send() method
returns "TRUE or a PEAR_Error object, if fails" and I just can't figure
out how to use that. PEAR online manual doesn't include an example of
error handling, at least in this chapter, and I'm rather new to object
oriented programming. I'd greatly appreciate a little example.
--
--
-- Álvaro G. Vicario - Burgos, Spain
--
Jul 17 '05 #1
2 5825
Hello,

On 10/28/2003 01:37 PM, Alvaro G Vicario wrote:
I'm trying to send e-mail using PEAR's Mail class--for testing purposes
actually, I've never had any problem with conventional mail(). This is
what my code looks like:

$mail_object=&M ail::factory('s endmail', $params);
if($mail_object->send($to, $headers, $body)){
header('Locatio n: '.$url_ok);
}else{
header('Locatio n: '.$url_ko);
}

This works (i.e., sends mail) but I know it isn't fine. My code never
shows any error, even after removing sendmail link... The send() method
returns "TRUE or a PEAR_Error object, if fails" and I just can't figure
out how to use that. PEAR online manual doesn't include an example of
error handling, at least in this chapter, and I'm rather new to object
oriented programming. I'd greatly appreciate a little example.


I don't use PEAR so I can't tell you what is wrong. However, I can
recommend this other class for composing and sending messages that also
has a sub-class specialized in deliverying messages directly with the
sendmail program. I can assure you that when the sendmail program is
missing, it will fail returning false and you can check the error class
variable to know more about the failure.

http://www.phpclasses.org/mimemessage

--

Regards,
Manuel Lemos

Free ready to use OOP components written in PHP
http://www.phpclasses.org/

Jul 17 '05 #2
*** Manuel Lemos escribió/wrote (6:16:34 29/10/2003):
I can assure you that when the sendmail program is missing, it will
fail returning false and you can check the error class variable to
know more about the failure.

http://www.phpclasses.org/mimemessage


Thank you for your remark, I didn't know about this class repository.

About PEAR, I finally got some inspiration. I guess you just have to
test returned value against true using the "===" operator and, if you
need further info in case or error, you can save that value into a
variable and just access its methods.
--
--
-- Álvaro G. Vicario - Burgos, Spain
--
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1500
by: Corey | last post by:
I'm running Windows/Outlook XP with mail routed through POP3/SMTP university servers. Abruptly, I am no longer able to send mail, though receiving works fine. I get an error message saying that Outlook couldn't connect with the outgoing server. No account settings have changed (I've checked) and I can still telnet to the SMTP server (but not through port 25)and send mail through a web-based university system. I do not have any Norton...
1
1255
by: eric | last post by:
Hello, I write a simple code to send email via my webpage. But there is no errors in the program when I trace it, and NO EMAIL get received in my hotmail box. Any idea? Seems all emails not been sent, thanks I am sure there is no send email authentication for password, but I am not sure whether the MyMail.from is correct Thank try { MailMessage MyMail = new MailMessage(); MyMail.To = "xxx@hotmail.com"; MyMail.From = "xxx@xxx.net";
0
1285
by: Jim Mitchell | last post by:
I like to display my web site in a window so that users can use the "Send Page" function in IE to mail their output using their client side Outlook program. The problem is that I always get an anoying textbox with some long code showing up in the page. I have tried the following.... 1) Post the innerHTML of a table or form using xml_http to a database and
3
2136
by: marsandys | last post by:
Hello, I have this code below, which I am trying to have it send HTML formatted mail with embedded images. I can get this to send the mail, but it spits out a bunch of junk . I know this should be pretty simple, but I have been pulling my hair out for hours with this. :/ Can someone smart pleaseeee help me tweak this code to work? <?php // Read POST request params into global vars
1
3116
by: mayanksrmcem | last post by:
I need ur help. I want to send emails through php code. but there are some problems n i'm not able to understand the actual problems. the code , i've used is as followes---- <?php if (isset($_REQUEST)) { $to=$_REQUEST; $sub=$_REQUEST;
0
1106
by: Amit Singla | last post by:
Hi plz tell me How mail send through cdosys.dll Thanks & Regards Amit Singla
1
1653
by: Kevien Lee | last post by:
Hi, When use the SmtpClient class,it is easy to send an e-mail,but how to konw that if the mail send successful,such as timeout and so on? can anyone advice me? Thanks
7
3483
by: redblue | last post by:
Hi all, i am new in php, I looked lots of example from Forum and tried online server but its nt work at all, i know i may be doing great mistake to sending HTML mail. last time i tried this code beloo, pls give me idea what is the erroe and its say "Mail Failed' <?php $to = 'example@test.com'; $subject = 'Test HTML email'; $random_hash = md5(date('r', time())); $headers = "From: webmaster@example.com\r\nReply-To:...
0
778
by: jayanthnadig | last post by:
Hi All, in our .Net(C#) windows application a modaless window will open with a textbox in focus. we have to enter the value in textbox programatically and close that window. is that possible using Send Keys? please help me. it's very urgent. Jayanth
0
9639
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9479
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
10311
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...
0
10146
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10080
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,...
1
7492
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
5378
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
5509
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2874
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.