Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 16

Thread: emails in php

  1. #1
    New Coder
    Join Date
    Sep 2002
    Location
    Nottingham, England, UK
    Posts
    66
    Thanks
    0
    Thanked 0 Times in 0 Posts

    emails in php

    Hi all,

    I am trying to send an email in php but I keep getting error messages. Below is my code and error message:

    the code----

    <?php

    $message="test blah blah blah";
    mail("habibrazak@yahoo.co.uk","Test Email in PHP", $message);

    ?>

    The error message I am getting is:

    Failed to Connect in c:\phpdev\www\test\thankyou.php on line 14

    Any ideas why I am getting this error???

    HR

  • #2
    New Coder
    Join Date
    Mar 2003
    Location
    Israel
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Did you told the form to...
    <form action="..."> ?? If so delete what you printed in the action place...

    You can try to send the user to a thank you page after the email is sent with this code...
    PHP Code:
    <?php 

    $message
    ="test blah blah blah"
    $mail=mail("habibrazak@yahoo.co.uk","Test Email in PHP"$message);
    if(
    $mail){
    header("location: [url]http://.../thankyou.php[/url]");}
    if(!
    $mail){
    print 
    "ERROR...";}

    ?>
    Remember that if you use the header function the code has to be placed above the <html> tag or it will show an error!

  • #3
    New Coder
    Join Date
    Sep 2002
    Location
    Nottingham, England, UK
    Posts
    66
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi Sleeping Danny,

    I am not using forms to send the email in php. Must I use forms to send emails?

    What I am trying to achieve is use values for certain variables from a text file (firstly, is this possible?) and then send these values via email to myself. The recepient email address, subject, will always stay the same. I tried to use the mail function (look at first posting above) in my thankyou.php page, when the page loads it should send me an email with the test data. But I keep getting errors.

    If anyone knows how I can send an email with dummy fields or data - greatly appreciated.

    Also can someone confirm whether I need to have a form in order to send an email - I am under the assumption that the mail() can be used anywhere, irrespective of a form.

    Once again thankyou for your help.
    Last edited by habib; 03-17-2003 at 04:09 PM.

  • #4
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    It failed because you haven't got an smtp server on your pc, and no, you don't need to use a form at all if you're sending a preset email, like "welcome to my site ... thanks for joining" etc, if you're wanting ppl to send you emails, then you'd need a form

    I believe php-gtk is an smtp server? Firepages is creating this app, so maybe he can fill you in with what it is/does
    Last edited by Nightfire; 03-17-2003 at 05:29 PM.

  • #5
    New Coder
    Join Date
    Sep 2002
    Location
    Nottingham, England, UK
    Posts
    66
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thankyou

    Thankyou NightFire,

    That makes sense now, I uploaded the page to my host and yes that works fine.

    X c lent

    P.s I have 3 pages which have forms on them, these fields are then passed on from one page to the next page and on the final page the details are confirmed. If I want to use the values for these variables in my email how would I do this?

    I.e :User enters in their contact details and these fields are passed on to products.php where the user selects a product.
    These details are passed on to confirm.php where the details are echoed out for the user to confirm. When the user clicks next the thankyou.php page is shown and an email is sent to me with the user contact details and products chosen.

    Thanks

  • #6
    Regular Coder
    Join Date
    Jul 2002
    Location
    Canada, eh?
    Posts
    133
    Thanks
    2
    Thanked 3 Times in 3 Posts
    This same thing is happening with me. I do not have a SMTP server.

    Does anyone know where a good one is, and how I could configure PHP to use it?

    (Maybe it'd help habib too :-p)

  • #7
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    This sometimes works, but most the time it won't. Find the php.ini file, open that up and then search for (it's around line 579)

    [mail function]
    ; For Win32 only.
    SMTP = localhost

    Change localhost to your ISP smtp address, like

    [mail function]
    ; For Win32 only.
    SMTP = mail.myisp.com

  • #8
    Regular Coder
    Join Date
    Jun 2002
    Location
    Montreal, Canada
    Posts
    644
    Thanks
    0
    Thanked 0 Times in 0 Posts
    but what if your ISP requires authentication?

  • #9
    Regular Coder
    Join Date
    Nov 2002
    Location
    Bristol, UK
    Posts
    932
    Thanks
    0
    Thanked 0 Times in 0 Posts
    you guys desperately need my SO_MAIL script

    It replaces mail() and lets you set loads of stuff

    I have attached v1.3 however v1.4 will be complete in the next day or so, and v2.0 by the end of next week, because I have to do some extras for a client

    enjoy!

    ::] krycek [::
    Attached Files Attached Files
    ithium | SOAPI | SDP | PTPScript manual
    "ithium is a non-profit webhost, which is pretty much unique. The mission of ithium is to provide free hosting resources for worthwhile and needy non-profit projects, which otherwise may not be able to obtain such facilities. The money from commercial customers goes to maintain ithium's servers and further development."

  • #10
    Regular Coder
    Join Date
    Nov 2002
    Location
    Bristol, UK
    Posts
    932
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I could only upload one file at a time, plus I had to put .txt on the end. Please remove the .txt

    Here is the configuration script for that email() function

    ::] krycek [::
    Attached Files Attached Files
    ithium | SOAPI | SDP | PTPScript manual
    "ithium is a non-profit webhost, which is pretty much unique. The mission of ithium is to provide free hosting resources for worthwhile and needy non-profit projects, which otherwise may not be able to obtain such facilities. The money from commercial customers goes to maintain ithium's servers and further development."

  • #11
    Regular Coder
    Join Date
    Nov 2002
    Location
    Bristol, UK
    Posts
    932
    Thanks
    0
    Thanked 0 Times in 0 Posts
    OK, I use this stuff extensively and I have not had any bugs, but if you do have any then please tell me. Can anyone who downloads and uses my code also keep me posted, because I would love to know who uses this stuff

    Broken down versions of this script have already appeared in certain places and there's no way to prove it was from my script, but it's fishy... basically if you see a script like this it's likely to have come from me in some form at some time, because I have been developing this mailer for a while

    Have fun!

    ::] krycek [::
    ithium | SOAPI | SDP | PTPScript manual
    "ithium is a non-profit webhost, which is pretty much unique. The mission of ithium is to provide free hosting resources for worthwhile and needy non-profit projects, which otherwise may not be able to obtain such facilities. The money from commercial customers goes to maintain ithium's servers and further development."

  • #12
    Regular Coder
    Join Date
    Nov 2002
    Location
    Bristol, UK
    Posts
    932
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Oh yeah, also, I use SciTE to develop a lot of my code nowadays, because I have modded the distribution so that the syntax colouring is more to my liking

    I include a screenshot here for your viewing pleasure! (I can't attach it, it's too big lol)

    www.soapi.com/scite_screenshot.gif

    If you want my custom SciTE settings, just ask

    ::] krycek [::
    ithium | SOAPI | SDP | PTPScript manual
    "ithium is a non-profit webhost, which is pretty much unique. The mission of ithium is to provide free hosting resources for worthwhile and needy non-profit projects, which otherwise may not be able to obtain such facilities. The money from commercial customers goes to maintain ithium's servers and further development."

  • #13
    Regular Coder
    Join Date
    Nov 2002
    Location
    Bristol, UK
    Posts
    932
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I notice that 7 people have downloaded the mail functions, but no-one has downloaded the config script...

    you need BOTH, people! or else it will not work

    ::] krycek [::
    ithium | SOAPI | SDP | PTPScript manual
    "ithium is a non-profit webhost, which is pretty much unique. The mission of ithium is to provide free hosting resources for worthwhile and needy non-profit projects, which otherwise may not be able to obtain such facilities. The money from commercial customers goes to maintain ithium's servers and further development."

  • #14
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    lol

    I just got scite for using with c++, it's a nice editor Use it for everything now and got rid of editpad classic after 3 years

  • #15
    Regular Coder
    Join Date
    Sep 2002
    Location
    Nottingham, UK
    Posts
    110
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Sending a confirmation email

    Hi all, I followed the above method to send emails in php - thanx Habib n Firepages. I know want to take this one step further. I send an email using the following code:

    <? php
    if ($products=="yes") {
    $to="products@sarah.mydomain.com";
    $subject="Product Info you required";
    $message.="Hi, blah blah blah.....";
    }

    if($geninfo=="yes") {
    $to="enquiries@sarah.mydomain.com";
    $subject="General Enquiry";
    $message.="Hi, blah blah blah.....";
    }

    mail($to, $subject, $message);

    At the moment depending on which variable is passed I get the relevant email. I now want to send myself one type of email (i.e using above code), and send the sender a confirmation email - this would have a different subject, body text, etc.

    What is the best way of doing this?
    (would i use $Bcc or is there a better way to do this?)

    Sarah
    You are not a human being having a spiritual experience, your a spiritual
    being having a human experience.


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •