473,587 Members | 2,489 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

mail() with authentication doesn't work

1 New Member
I do not have proper excellence at php programming. I wrote below script after reading several articles. Anyway that form-to-mail script doesn't work. form action is connected to following code

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. require_once "send1.php";
  3.  
  4. $from = "Sandra Sender <user@myweb.com.com>"; 
  5. $to = "Ramona Recipient <myemail@gmail.com>";
  6. $subject = "Hi!";
  7. $body = "Hi,\n\nHow are you?";
  8.  
  9. $host = " mail.myweb.com";
  10. $username = "user@myweb.com";
  11. $password = "mypassword";
  12.  
  13. $headers = array ('From' => $from,
  14.   'To' => $to, 
  15.   'Subject' => $subject);
  16. $smtp = Mail::factory('smtp',
  17.   array ('host' => $host,
  18.     'auth' => true,
  19.     'username' => $username,
  20.     'password' => $password)); 
  21.  
  22. $mail = $smtp->send($to, $headers, $body);
  23.  
  24. if (PEAR::isError($mail)) {
  25.   echo("<p>" . $mail->getMessage() . "</p>");
  26. } else {
  27.   echo("<p>Message successfully sent!</p>"); 
  28. }
  29. ?>
  30.  
send1.php is as follows.
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $to = "myemail@gmail.com";
  3. $subject = "Hi!"; 
  4. $body = "Hi,\n\nHow are you?";
  5. if (mail($to, $subject, $body)) {
  6. echo("<p>Message successfully sent!</p>");
  7. } else {
  8. echo("<p>Message delivery failed...</p>"); 
  9. }
  10. ?>
  11.  
this gets a error massage as follows.
Expand|Select|Wrap|Line Numbers
  1. Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in ....
  2.  
  3. Message delivery failed...
  4.  
  5.  
  6. Fatal error: Class 'Mail' not found in D:\websites\fff\fff.com\wwwroot\send.php on line 16
  7.  
--------------------------------------------

I don't have a server and i'm taking server from a remote company. they says mail server authentication is the prob. anyway it doesn't work.

please help me...

thanks.
Nov 5 '07 #1
1 2237
Atli
5,058 Recognized Expert Expert
Hi. Welcome to TSDN!

Your fist warning says it all, really:
Expand|Select|Wrap|Line Numbers
  1. Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in ....
  2.  
So, as the error mentions, try giving the "smtp_port" and "SMTP" settings proper values.
Like for example:
Expand|Select|Wrap|Line Numbers
  1. ini_set("smtp_port", 25);
  2. ini_set("SMTP", "mail.example.mysmtpserver.com");
  3.  
These values are obviously made up. You will have to replace them with real values.
Nov 10 '07 #2

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

Similar topics

0
2449
by: Google Mike | last post by:
There seems to be a lot of white noise in trying to understand SMTP that requires authentication when searching the newsgroups via Google Groups or searching the PHP.net website. The PHP fsockopen API's notes on php.net provide the routine to connect, unauthenticated, to send messages. But if you need authentication, people want you to...
8
5460
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- Hello, I have a very simple problem but cannot seem to figure it out. I have a very simple php script that sends a test email to myself. When I...
4
1666
by: Brett Porter | last post by:
Hi, My ASP.Net applications frequently make use of the System.Web.Mail namespace to send emails. I have set SmtpMail.SmtpServer = "localhost" and the emails send out fine UNTIL an email is sent to the same address as the server / website address i.e. If the web address is www.servername.com an email sent using SMTPMail to...
3
3018
by: RN | last post by:
I am tired of sending mail from the built-in SMTP service for so many reasons (errors are nondescriptive in the event log, it doesn't let me control which IP address it sends from, and it identifies itself as the computer name which is not in domain.com format, triggering spam filter problems). Instead, I want to have my code send through...
1
8168
by: Eric Sheu | last post by:
Greetings, I have been searching the web like mad for a solution to my SMTP problem. I am using Windows Server 2003 and ASP.NET 2.0 w/ C# to send out e-mails from a web site I have created to the members of my organization. I think my problem is incorrectly setting the settings on my server or an authentication problem. Here is the code I...
6
2519
by: rekaeps | last post by:
We are developing an ASP.NET 2.0 (C#) application, and I'm having troubles sending e-mail from the server when accessing the web site from a separate client computer. Also, in the same scenario, I'm having trouble writing to the server's event log. Here's some details: Server and workstation both in the same workgroup Logged into server...
3
2353
by: dnuos | last post by:
We are developing an ASP.NET 2.0 (C#) application, and I'm having troubles sending e-mail from the server when accessing the web site from a separate client computer. Here's some details: Server and client computers both in the same workgroup Logged into server as local Administrator Logged into client as a local user that is only in the...
6
1420
by: AbraAbraCadabra | last post by:
Ok I think I've almost got my problem solved. I am using this code to send mail. I am simply pasting it into an .ASP page. Why doesn't this code work? I do have ..NET 2.0 installed, but I haven't done any configuration to it. Am I missing something? 'Create a new MailMessage object and specify the"From" and "To" addresses Dim Email...
11
2704
by: ibiza | last post by:
Hi all, I am trying to use the System.Net.Mail class for the first time, with ASP.NET 2.0. I setup everything according to http://www.codeproject.com/aspnet/EasySMTP_package.asp, which gives me a working environment for sending mails. I am sure the code is correct, there are no errors and everything seems
0
7923
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...
0
8349
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...
1
7974
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...
0
8221
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6629
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...
0
3882
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2364
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
1
1455
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1192
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...

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.