|
|
A Question About The Php Mail() Function | ||
Discussion by mrdee with 12 Replies.
Last Update: February 15, 2012, 2:28 pm | |||
![]() |
|
|
In the php.ini file, the functions for mail and smtp say the following (for as far as I know, as i am a PHP novice):
CODE
[mail function]; For Win32 only.
SMTP = localhost
smtp_port = 25
; For Win32 only.
;sendmail_from = frankied[at]****music.plus.com
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path =
; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =
I don't know what I need to change, also, I changed the original to my own email address (here masked out for security reasons), but that line is still commented.
I also uploaded two scripts, one called mail.php, code below:
CODE
<?php
$to = "fd******[at]gmail.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "webbie[at]v****-f******.org.**";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>
Once again, i have masked my email address for security reasons.
and mailform.php, code below:
<html>
<body>
CODE
<?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
{
//send email
$email = $_REQUEST['webbie[at]vl***-f********.org.**'] ;
$subject = $_REQUEST['Proberen'] ;
$message = $_REQUEST['Ratatatatatatatataaaaaaaaaaaaaa'] ;
mail("fde*******[at]gmail.com", "$subject",
$message, "From:" . $email);
echo "Thank you for using our mail form";
}
else
//if "email" is not filled out, display the form
{
echo "<form method='post' action='mailform.php'>
Email: <input name='email' type='text' /><br />
Subject: <input name='subject' type='text' /><br />
Message:<br />
<textarea name='message' rows='15' cols='40'>
</textarea><br />
<input type='submit' />
</form>";
}
?>
</body>
</html>
Same here, emails masked for security reasons.
Now, when I run both scripts, not one error is generated, and I get the message the mail has been sent successfully, but no mail ever arrives.
Does anyone know what I am doing wrong and how I can make the mail() function work so I can test scripts locally, scripts that involve sending emails?
Any help will be much appreciated.
Thank you.
But do I have to do it in my script, or can I set the smtp sever in my php.ini or similar?
QUOTE (mrdee)
But do I have to do it in my script, or can I set the smtp sever in my php.ini or similar?
Link: view Post: 514098
You can set it in php.in or use through your script, decision is upto you. php.ini way is simple just to modify two lines.
and if you want it through script, i prefer you to read about mail() syntax and its uses.
CODE
[mail function]
; For Win32 only.
SMTP = smtp.o2.co.uk
smtp_port = 25
That does not seem to do the trick, though.
http://forum.o2.co.uk/viewtopic.php?t=173
may help you in this way.
However, I know all that, I know it is port 25, and I know you have to enter your full emailaddress as username and your password, but the topic you referred me to does not utter a single word about how to implement the last two elements (username and password) into your php.ini file.
CODE
;auth_username=;auth_password=
and if those are present; remove ";" and set your O2 username and password.
if those are not present add those line without ";" just after smtp port setting.
Another way is by using ini_set() in your script; which not required you to edit php.ini.
CODE
ini_set(SMTP, 'Write your SMTP SERVER here');ini_set(smtp_port, 'Write smtp port here ex. 25');
ini_set(auth_username, 'Write SMTP SERVER username here');
ini_set(auth_password,'Write SMTO SERVER authentication password here');
ini_set(mail.log, 'Set path for mail log not necessary but will helpful to sort out errors and problems');
Please if it help you don't forget to vote it up by pressing up green button.
However, none of the solutions have worked, I'm afraid.
Thank you anyway.
can you post your editing or changes here.
Ohhh, how stupid i am.
it was my silly mistake. Please enclose first argument of ini_set() in '' .
Sorry for mistake. And
Can't send any errors, couldn't set up a log file.
However, here are the changes I made in my php.ini:
CODE
[mail function]; For Win32 only.
SMTP = smtp.o2.co.uk
smtp_port = 25
auth_username="frankie_deschacht@o2.co.uk"
auth_password="**********"
; For Win32 only.
sendmail_from ="frankied@jazzmusic.plus.com"
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path =
Thank you for all your help.
Similar Topics:
PHP Function To Add Previous and Ne...
A Question About Php Mail
Php Mail Function Not Working!
Using Randomly Generated And Integrating A Retweet/share Button (0)
|
(3) More Advice Needed From Php Experts.
|
Loading...
HOME 






