hi there... i would like to know if anyone could look at my mail script and tell me if there is anything clearly wrong, or missing... -
<?php
-
$to = $_POST['email'];
-
$subject = 'test';
-
$random_hash = md5(date('r', time()));
-
-
$headers = "From: me@example.com\nReply-To: me@example.com";
-
$headers .= "\nContent-Type: multipart/alternative; boundary=\"PHP-alt-".$random_hash."\"";
-
-
ob_start();
-
?>
-
-
--PHP-alt-<?php echo $random_hash; ?>
-
Content-Type: text/plain; charset="iso-8859-1"
-
Content-Transfer-Encoding: 8bit
-
-
<?php
-
echo nl2br ("this is a basic text email message.\nYour Email doesn't accept HTML email.");
-
?>
-
-
--PHP-alt-<?php echo $random_hash; ?>
-
Content-Type: text/html; charset="iso-8859-1"
-
Content-Transfer-Encoding: 8bit
-
-
<?php
-
echo ("<h2>this is an HTML email</h2>");
-
echo ("<p>Your email accepts <b>HTML</b> formatting.</p>");
-
?>
-
-
--PHP-alt-<?php echo $random_hash; ?>--
-
-
-
-
<?
-
$message = ob_get_clean();
-
mail ($to, $subject, $message, $headers);
-
# after message is sent, goto Google.
-
header ("Location: http://www.google.com");
-
?>
-
i'm planning on just using the PHP Mail() function... i'm under the assumption that it's possible to send Text and HTML emails without having to use PHP Mailer or something similar. please let me know if i'm wrong here...
thanks in advance
13 3581
anyone at all? i could really use someone's help.
What are you looking for? You have not asked us a question, which makes it quite difficult to answer your question.
The mail() function in PHP relies on your server's SMTP settings. You will need to have an SMTP server running, and have PHP configured properly to use it.
Atli 5,058
Expert 4TB
Hi.
Im not sure what the problem with your script is.
Here is a sample script of how to use the mail() function tho: Sample script
sorry for the confusion... i was simply posting this script to see if anyone could spot any syntax errors or something else that would be way wrong with it...
thanks for making me realize that smtp email is required for the sendmail function... i was under the impression that you could write any address is the $header From: section for it to work... but i suppose it's a security/spam risk to allow that... i guess i'll have to wait until monday to test my php mail scripts when i order my server space...
hello again... i recently subscribed to a server so i'm able to test my PHP Mail() scripts. this example above sends, but when i open the email (in my GMAIL account), body of the email is missing (neither the text or html versions are displayed)...
can anyone tell me what's wrong with the code?
Atli 5,058
Expert 4TB
I doubt this will change anything, but you could try changing the "\n" in the header to "\r\n".
"\r\n" is the Windows version of the old "\n" unix newline character.
I doubt this will change anything, but you could try changing the "\n" in the header to "\r\n".
"\r\n" is the Windows version of the old "\n" unix newline character.
hi there... i'm on a *nix server... so \r isn't necessary...
hi there... i'm on a *nix server... so \r isn't necessary...
also... this is exactly what is being sent to the email address... but it seems fine to me... and if this is showing up when i click 'show original message' why isn't anything appearing in the email? -
<removed - contains personal information that could be used for malicious purposes>
-
also... this is exactly what is being sent to the email address... but it seems fine to me... and if this is showing up when i click 'show original message' why isn't anything appearing in the email? - <removed - contains personal information that could be used for malicious purposes>
I am not sure if this is the cause, but try a different encoding. MIME "should" be accepted by all mail servers. http://us.php.net/function.mail for examples on sending HTML email.
I am not sure if this is the cause, but try a different encoding. MIME "should" be accepted by all mail servers. http://us.php.net/function.mail for examples on sending HTML email.
hello... i've changed the charset to "us-ascii" and "utf-8", i've also changed the Content-Transfer-Encoding: 8bit to both 7bit and base64... it's still not displaying in my gmail...
i'm comparing my own test email to other multipart/alternitive messages i've received that do display in gmail... the code in the messages that do display is the same as my code...
i'm afraid i'm stuck...
it seems to work now... but i haven't fully tested it...
i had to remove the very last boundary that was included in my script after the HTML code...
hi guys...
i ve almost same problem...i am using argosoft mail server pro and added a domain called moh.com with a user named kif. The website is not yet published, but we have an internal network that we use using the mail server. Now, I have my email address <email removed>, and from my php file, it sends it. At least, thats what I see in my mail server log file: that it has sent a msg to <email removed>. But when I log on to my <email removed>.com, I dont get the msg. What could be the wrong?
hi guys...
i ve almost same problem...i am using argosoft mail server pro and added a domain called moh.com with a user named kif. The website is not yet published, but we have an internal network that we use using the mail server. Now, I have my email address <email removed>, and from my php file, it sends it. At least, thats what I see in my mail server log file: that it has sent a msg to <email removed>. But when I log on to my <email removed>.com, I dont get the msg. What could be the wrong?
hi samvb... if you have the same problem as i do, then you're boundaries are not correct... however, i've learned that sending multipart/alternitive mail thru PHP can be quite complex, and therefore your problem could be one of many things.
have you read thru the mail thread on php.net? there are quite a few examples and explanations that you can read... and you're also welcome to post your code here so others can possibly see exactly what the problem is... i hope this link helps, as it's what helped me. http://ca3.php.net/mail
good luck
Sign in to post your reply or Sign up for a free account.
Similar topics
by: pee2pee |
last post by:
Hi,
I have below code:
<html>
<head>
<title>Contacting Worldpay, Please wait.......</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body...
|
by: Frank R. Suchy |
last post by:
Hi there,
the task:
Any mail that drops into a specified mailbox shall cause a (php-)script to
immediately react with some action.
Quite a common task, isn't it?
I could use e.g. cron to let...
|
by: Remon Huijts |
last post by:
Hi,
When I use php mail() in a script on my localhost to send an HTML
message to an e-mailaccount on my online host, all is fine.
When I use php mail() in a script on my online host to send an...
|
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
--------------------------------------------------------------------------------
...
|
by: Joe via DotNetMonster.com |
last post by:
Hi,
I'm trying out a test mail script but it doesn't seem to work. The error I
get is that mail is not declared on the mail.To line.
Also, do I need to specify the SMTP Server? I have it...
|
by: job kazan |
last post by:
Can anyone suggest the best and easiest platform for the following job,
possible freelancer and approximate budget for this:
"It must be a script that has as an input a long code from the...
|
by: fdu.xiaojf |
last post by:
Hi,
I just want to send a very simple email from within python.
I think the standard module of smtpd in python can do this, but I
haven't found documents about how to use it after googleing....
|
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...
|
by: krik |
last post by:
Hello,
I would like to send a mail via a script with customized From field or at least with Reply-To. This email is sent by a monitoring server via a cron job and the users should see this mail as...
|
by: Call Me Tom |
last post by:
The following simple script receives data from a form and sends me an
email. It works fine on my testing machine (xampp for windows).
However, when I upload it to my web host, the script processes...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |