473,795 Members | 3,081 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to use the mail() function in php?

Nert
64 New Member
hello every one, i need help..

how can i use the mail() funtion in php? when ever i execute the mail function i continuesly receive this error message:

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...
what do i need to do in order for me to connect with my localhost mailserver?

can anyone help me with this?
thanks in advance..(^_^)

--nert
Nov 21 '06
13 21337
Colby
2 New Member
Ronald,

I am also looking for a solution for sending mail from forms using PHP in Windows. I researched your replies to the previous person and checked my PHP.ini and code to see if it complied with your instructions. It does comply and I and getting the error: "Warning: mail() {function.funct ion]: smpt DERVER RESPONSE:530 AUTHENTICATION REQUIRED - FOR HELP GO TO HTTP://HELP.YAHOO.COM/HELP/US/SBC/CL...OP/POP-11.HTML IN d:\iNTERNET\aPA CHED2.2\HTDOCS\ MYSITE\messageS ent.php on line 8.

The error points to my code on line 8 of the messageSent.php code:
Code goes here:
[code]
<?php
$to = "yourname@yours erver.com";
$subject = "This is the message subject";
$body = "this is the message body";
$headers = "From: yourname@yourse rver.com\n";
mail($to,$subje ct,$body,$heade rs); ; this is line 8 of the code
?>

when the code attempts to send the message to my ISP's smtp server, the smtp server refuses the message because , I believe that there is no authentication set for it to use my isp's smtp server.

I use Yahoo and when I went to HTTP://HELP.YAHOO.COM/HELP/US/SBC/CLSL/MAIL/POP/POP-11.HTML,
I found that Yahoo only accepts certain email clients and Yahoo lists them.

There is also some discussion about paying for access to a smpt server, if you wish to send mail from your own site. I may be reading something wrong and I am looking for second opinions and some direction. Can anyone else provide some insight regarding how Yahoo or other ISPs handle this issue.

This may be why so many people are failing to be able to use smtp from their local host servers.

This is code from my PHP.ini file:
Expand|Select|Wrap|Line Numbers
  1. [mail function]
  2. ; For Win32 only.
  3. SMTP = smtp.pacbell.yahoo.com
  4. smtp_port = 25
  5.  
  6. ; For Win32 only.
  7. ;sendmail_from = me@pacbell.net
  8.  
  9. ; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
  10. ;sendmail_path =
  11.  
  12. ; Force the addition of the specified parameters to be passed as extra parameters
  13. ; to the sendmail binary. These parameters will always replace the value of
  14. ; the 5th parameter to mail(), even in safe mode.
  15. ;mail.force_extra_parameters =
  16.  

This is the code from my form:
Expand|Select|Wrap|Line Numbers
  1.     <td><form id="form2" name="form2" method="post" action="">
  2.       <textarea name="body" cols="55" id="body"></textarea>
  3.     </form>    </td>
  4.   </tr>
  5.   <tr>
  6.     <td>&nbsp;</td>
  7.     <td><form id="form3" name="form3" method="post" action="">
  8.       <input type="submit" name="Submit" value="Submit" />
  9.     </form>    </td>
  10.   </tr>
  11.  
The form and this code work well. My ISP seems to refuse to take messages from outside servers and or email clients other than those listed in the help page.

Is their a work around for this?
Jul 2 '07 #11
kovik
1,044 Recognized Expert Top Contributor
Why is everyone hijacking this thread?

Anyway, the simplest way to send mail using SMTP is to use SwiftMailer. It is very easy to use, extremely object-oriented, and has it's own support board at DevNetwork.
Jul 2 '07 #12
Colby
2 New Member
Why is everyone hijacking this thread?

Anyway, the simplest way to send mail using SMTP is to use SwiftMailer. It is very easy to use, extremely object-oriented, and has it's own support board at DevNetwork.
Thanks for the information. I will try Swiftmailer.
Jul 3 '07 #13
eragon
431 Contributor
sorry to use this thread, but its relavant to my problems, you see, therea a forum on my webite that is SUPPOSED to send me an email verification whenever someone posts a new thread, but it dosnt work.

heres the error:

Expand|Select|Wrap|Line Numbers
  1. Warning: mail() [function.mail]: Safety Restriction in effect. The mail() command is not allowed, contact the admin. in /forums/mboard.php on line 470
this file can be found at here
Jul 6 '07 #14

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

Similar topics

4
1838
by: Geoff Soper | last post by:
I'm using the mail() function to send e-mails. The first argument to the function is the e-mail address the mail will be sent to. I understand this should just be in the format 'address@domain' and not '"Name" <address@domain>' and that if I want to specify the name of the recipient as well as the address of the recipient I should pass it as an addition header. This works fine locally under Windows and Apache but remotely under Linux and...
2
3324
by: Web Master | last post by:
Hi, I am having a little issue with Jacks Form mail php script. I have installed it and configured the form to get it to work, but for some bizarre reason I have 2 issues I can't seem to debug. Issue#1: I get 2 copies of the form that gets submitted each time. Issue#2: The header does not display the "FROM" information in Outlook, but I can see the From information in my email spam filter
7
2624
by: Jim Seymour | last post by:
I have a contact form that uses PHP's mail() function. It recently came to my attention that (some?) MS-Windows mail servers may not properly process data given to the mail() function that's only newline-terminated. The mail() function takes up to five parameters: mail(recipient, subject, message, ]) The ones of interest here are the first four. The questions are
2
2387
by: Groupe Eurower | last post by:
Hi, I would like contribute to the PHP development but i don't really know where i can submit my codes ! In fact, i'm a Web Hosting and i authorize the utilisation of the mail() function. Meanwhile, this function permit to send mail anonyme ! (the sender is the apache user in fact)
3
2257
by: Karuna | last post by:
Hi everybody, I have been trying to write a simple mail script using PHP and apache on Windows XP. Eventhough the script is saying that the mail is successfully sent, I am unable get it in my mailbox(I have given my mail address in $to). I am using the mail() function and I have made the following changes in php.ini ; For Win32 only. SMTP = localhost
8
5483
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 debug it in PHP designer, it works with no problems, I get the test email. If
3
3301
uranuskid
by: uranuskid | last post by:
Hey folks, I was going to include a contact form on my website. Well, in the first place that seemed an easy thing to do with a form that prompts a PHP file validating the input vaiables and using it's mail () function to send the mail. However, as I got more into that topic I realized that one should be really concerned about the validation part to prevent spam abuse. There are shiploads of 'mail scripts' available with each of them has...
2
2676
by: Ruud | last post by:
Just before leaving for a holiday my collegue modified this script. Now it won't send any body text (The data filled in on the form) and in an error condition it won't send any attachments either. Because I don't understand PHP I cannot find the error. Who is willing to help? regards Ruud
1
6860
by: maxxxxel | last post by:
Hi Can anyone help me with some asp code , I changed the code to use CDO.message instead of the old cdont.sys to send mail from a ASP webpage which works fine. Our problem is that when we send mail externally to a internet email site like Gmail the PDF is sent but is corrupted because CDOSYS ends up using binary encoding rather than Base64 encoding when creating the attachment. More information here: Anthonys Code My knowledge of ASP...
7
16930
by: mukeshrasm | last post by:
Hi I am no able to send mail and it is giving this error Warning: mail(): SMTP server response: 530 5.7.3 Client was not authenticated in c:\inetpub\wwwroot\eshop\includes\classes\email.php on line 522 and the code is: <?php /* $Id: email.php,v 1.12 2003/06/17 17:29:44 dgw_ Exp $
0
9672
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
10439
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
10215
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...
0
9043
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...
0
6783
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
5437
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
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3727
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
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.