473,883 Members | 3,034 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 21350
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
1842
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
3329
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
2629
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
2390
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
2261
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
5488
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
3303
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
2681
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
6866
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
16963
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
9797
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,...
1
10863
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
10422
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7977
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
7136
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
5807
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
6005
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4622
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
2
4228
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.