php mail... I did this ages before but I'm having problems with it. -
<?php
-
-
//--- Start mail script ---
-
-
$to = "address@gmail.com";
-
-
$from = "address@gmail.com";
-
-
$subject = "Please work";
-
-
$body = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit.";
-
-
$header = "Blah blah";
-
-
$success = mail($to, $subject, $body, $header);
-
-
if(!$success) {
-
echo "error";
-
} else {
-
echo "success";
-
}
-
-
//--- End mail script ---
-
-
?>
-
-
Can anyone explain why this won't work. I keep getting my "error" echo.
10 2077
The from should go into the 4th parameter (also called the header).
[PHP]<?php
//--- Start mail script ---
$to = "address@gmail.com";
$from = "address@gmail.com";
$subject = "Please work";
$body = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit.";
$header = "Blah blah";
$success = mail($to, $subject, $body, $from);
if(!$success) {
echo "error";
} else {
echo "success";
}
//--- End mail script ---
?>[/PHP]
Ronald :cool:
For some reason this still doesn't seem to work.
I even tried putting in the parameter without using variables it just won't work : (
I've never seen it assigned to a variable before. Whenever I've sent an e-mail or seen code for it it's always looked like:
[php]
$to = someone@domain.com
$subject = //whatever the subject is
$text = //body text of the e-mail
$headers = //e-mail headers
mail($to, $subject, $text, $headers);
[/php]
As I said, I haven't seen it been assigned to a variable before. I find it hard to believe that could be the problem. But I also find it hard to believe ronverdonk can be wrong.
Hope this helps
LB
I am very sorry, I made a mistype in the code I showed. I forgot to prefix the sender with the literal 'From: '. The following is correct, so it should be okay for you now.
[php]<?php
//--- Start mail script ---
$to = "address@gmail.com";
$from = "From: address@gmail.com";
$subject = "Please work";
$body = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit.";
$header = "Blah blah";
$success = mail($to, $subject, $body, $from);
if(!$success) {
echo "error";
} else {
echo "success";
}
//--- End mail script ---
?>
[/php]
Ronald :cool:
sender's email address should be appended in header
so you code should look like this -
$to="email@domain.com
-
$subject = "this i subjec\r\n";
-
$headers = "From: receipt@domain.com\r\n";
-
$headers .= "Reply-To:receipt@domaincom\r\n";
-
$headers .= "Return-Path: receipt@domain.com\r\n";
-
$body= "type your messege here ";
-
-
mail("$to","$subject","\n$body", "$headers\r");
$to="email@domain.com
$subject = "this i subjec\r\n";
$headers = "From: receipt@domain.com\r\n";
$headers .= "Reply-To:receipt@domaincom\r\n";
$headers .= "Return-Path: receipt@domain.com\r\n";
$body= "type your messege here ";
mail("$to","$subject","\n$body", "$headers\r");
From the mail settings in this case only the 'From: ' is required in the 4th mail parameters (also called headers in the docs). The other header content is nice but NOT mandatory.
Ronald :cool:
IT WON'T WORK!!! Aaargh! why?!?
even copying and pasting, won't work!?! -
-
$to = "email@gmail.com";
-
$subject = "Subject";
-
$body = "Body text and such stuff";
-
$header = "From: email@gmail.com";
-
-
$success = mail($to, $subject, $body, $header);
-
-
if(!$success) {
-
echo "error";
-
} else {
-
echo "sent";
-
}
-
-
Now from what I gather this should work provided that "email@gmail.com" is replaced with a valid address. But it doesn't! I keep getting "error". I even tried it without assigning the function to variable $success... same story. I don't understand what sort of minute syntax tithle is missing here.
I appriciate all the help, guys though this is UNIMAGINABLY trying :(
Okay... I ran phpinfo() and under the section called Configuration PHP CORE I got this... disable_functions: getmyinode, getopt, getrusage, extension_loaded, dl, mysql_pconnect, crack_check, crack_closedict, crack_getlastmessage, crack_opendict, fsockopen, pfsockopen, mysql_list_dbs, mysql_stat, ini_get, ini_get_all, ini_alter, ini_set, get_current_user, get_defined_constants, get_include_path, php_ini_scanned_files, php_uname, phpcredits, restore_include_path, set_include_path, set_time_limit, version_compare, zend_version, getmypid, getmyuid, getmygid, assert_options, assert, fopen, fwrite, fread, file, fpassthru, file, mail, opendir, readdir, closedir
This seems to be getting more complicated than i care for. Can anyone please tell me why are some functions disabled and why is mail one of those functions and how can i enable some of these function or can i not.
ronverdonk?
You most probably are running PHP in safe mode. That mode is set at installation of PHP. This mode disables the functions you mention, see also the list of disabled functions at Functions restricted/disabled by safe mode
The PHP safe mode is an attempt to solve the shared-server security problem. It is architecturally incorrect to try to solve this problem at the PHP level, but since the alternatives at the web server and OS levels aren't very realistic, many people, especially ISP's, use safe mode for now.
See the PHP manual for a discussion on safe mode at Safe Mode
If you installed PHP yourself, remove the safe mode. If not, you'd better have a talk with your server provider.
Ronald :cool:
Okay, thanks. I've emailed my server provider... they've promised a quick response so I'll see.
At least I can now stop bashing my head against the wall.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: praba kar |
last post by:
Dear All,
I have doubt regarding mail sending smtplib
module. The below code is I used to send a mail.
##########################################
import email.Message
import email.Utils...
|
by: Stuart Mueller |
last post by:
I have an exchange server, that I sometimes use to perform mail shots to
clients on our database, these can be upwards of 1000 at a time.
As we don't want different clients to see who we are...
|
by: Mr. x |
last post by:
Hello,
I am sending emails with Hebrew contents.
When receiving emails - I cannot see the Hebrew characters (it is not
outlook express configuration, because when receiving emails from friends -...
|
by: VB Programmer |
last post by:
I have an ASPX page where I send out emails through my mail server
mail.MyDomain.com. When I send emails to MyName@MyDomain.com it sends
PERFECTLY. When I try sending an email to any other address...
|
by: HoustonComputerGuy |
last post by:
I am working on getting my web applications moved to .Net 2.0 and am
having some problems with System.Net.Mail. I get the following error
when sending the mail:
System.Net.Mail.SmtpException was...
|
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...
|
by: HK |
last post by:
In VB.NET, I'm getting the exception "failure sending mail". I'm running VS
2005 on XP Home. This is a new install on a new PC. I've never had email
problems with VS 2003, and there I could...
|
by: mfleet1973 |
last post by:
Hello Again.
I have a program that sends e-mails as follows:
Try
Dim mail As New MailMessage
mail.To = "me@comp.com"
mail.From = "me@comp.com
mail.Subject = "Test"
mail.Body = "Testing123"
|
by: JoeP |
last post by:
Hi All,
How can I find the reason for such an error: Failure sending mail.
Some Code...
oMailMessage.IsBodyHtml = False
oMailMessage.Body = cEmailBody
Dim oSMTP As New SmtpClient...
|
by: =?Utf-8?B?R3V5IENvaGVu?= |
last post by:
Hi all
I use:
Dim message As New MailMessage(txtTo.Text, txtFrom.Text, txtSubject.Text,
txtBody.Text)
Dim emailClient As New SmtpClient(txtSMTPServer.Text)
emailClient.Send(message)
And its...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: Aliciasmith |
last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
|
by: giovanniandrean |
last post by:
The energy model is structured as follows and uses excel sheets to give input data:
1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
|
by: NeoPa |
last post by:
Hello everyone.
I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report).
I know it can be done by selecting :...
|
by: Teri B |
last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course.
0ne-to-many. One course many roles.
Then I created a report based on the Course form and...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM)
Please note that the UK and Europe revert to winter time on...
|
by: nia12 |
last post by:
Hi there,
I am very new to Access so apologies if any of this is obvious/not clear.
I am creating a data collection tool for health care employees to complete. It consists of a number of...
|
by: isladogs |
last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, Mike...
|
by: GKJR |
last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
| |