Problem with testing my email.php

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Re: Problem with testing my email.php

Postby Chico Felipe » 31. May 2013 18:31

Thank you very much Altrea! Glad to know this part is fine.

I am not sure how to configure the fake sendmail. Sorry, if I bother you with this. I don't know what part of the code I have to change and where exactly to put it?

Should I go to xampp/php/php.ini and change something there? I opened this file but it's very long so I am afraid to mess up something.

Or it is easier to download the alternatives you mentioned???

Anyway, thanks for your help and extreme patience with me!!! Appreciate it a lot.
Chico Felipe
 
Posts: 22
Joined: 31. May 2013 13:30
Operating System: Windows 7

Re: Problem with testing my email.php

Postby Altrea » 31. May 2013 18:54

Chico Felipe wrote:I am not sure how to configure the fake sendmail. Sorry, if I bother you with this. I don't know what part of the code I have to change and where exactly to put it?

You need to change C:\xampp\php\php.ini to change from mailtodisk.exe to sendmail.exe (search for the [mail function] block)
After that you need to specify the sendmail configuration in C:\xampp\sendmail\sendmail.ini
I haven't used sendmail for years, so i can't say anything more to this, sorry.

To use PHPMailer (which is a php class) you don't need to change anything in the configuration files. Simply download the class and include it to your code.
All the configuration parameter for the email sending can and have to be done in your/the code, so you just need to worry one time about configuration and after that you can simply bring email functionality by copy and paste the configured php files.
PHPMailer comes with some example files (e.g. for gmail) which already contains the basic configuration parameters so that you just need to input your username and password and ready for take off.

Chico Felipe wrote:Or it is easier to download the alternatives you mentioned???

The first step of configuration needs to be done for both so there none of them is easier than the other.
But PHPMailer is bulletproof has a very good documentation with many examples, an active community, etc etc.

At the end it's up to you which one to choose.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11926
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: Problem with testing my email.php

Postby Chico Felipe » 31. May 2013 19:00

Great! Thanks a lot for everything. I will try with PHPMailer because, from what you are telling me, it seems like a better option.

Do I still need a CAPTCHA or PHPMailer is safe enough???

Have a great day Altrea!!!
Chico Felipe
 
Posts: 22
Joined: 31. May 2013 13:30
Operating System: Windows 7

Re: Problem with testing my email.php

Postby Altrea » 31. May 2013 19:04

PHPMailer can send E-Mails very well, but it does not protect against Spam by itself.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11926
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: Problem with testing my email.php

Postby Chico Felipe » 31. May 2013 19:08

Ok. I will ad CAPTCHA then. I am reading now how to change PHPMailer and will try to make it work as soon as I figure out how to.

Thanks again, you rock!
Chico Felipe
 
Posts: 22
Joined: 31. May 2013 13:30
Operating System: Windows 7

Re: Problem with testing my email.php

Postby Altrea » 31. May 2013 19:10

If you have any problems to get PHPMailer working, let me know :)
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11926
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: Problem with testing my email.php

Postby Chico Felipe » 31. May 2013 19:34

Ok. I just downloaded PHPMailer. Not sure where to start from. It's still on my desktop, unzipped. I don't see any installation files. How can I run it? And where should I copy this whole folder?
Chico Felipe
 
Posts: 22
Joined: 31. May 2013 13:30
Operating System: Windows 7

Re: Problem with testing my email.php

Postby Altrea » 31. May 2013 20:41

Okay, i have done some testing myself with gmail. Lets do a practical example.

Assuming you are still in the folder C:\xampp\htdocs\email\ create a new subfolder in it called PHPMailer
In this folder simply extract the contents of the downloaded PHPMailer .zip archive (without the wrapping PHPMailer-master folder)

now you can use a sample code like this to connect and send mails:
Code: Select all
<?php
require_once('PHPMailer/class.phpmailer.php');

// You should do some data validation / data sanotation here
$name = $_REQUEST['name'] ;
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;

$mail = new PHPMailer();

// base parameters. working for me
$mail->IsSMTP(); // use SMTP
$mail->Host = "smtp.gmail.com"; // GMail
$mail->Port = 465;
$mail->SMTPSecure = "ssl";
$mail->SMTPAuth = true; // turn on SMTP authentication

// adjust these lines
$mail->Username = "YOUR-GMAIL-NAME@gmail.com";
$mail->Password = "YOUR-GMAIL-PASSWORD";
$mail->SetFrom($email, $name);
$mail->AddAddress($mail->Username);
$mail->Subject = "Feedback Form Results";
$mail->Body    = $message;

// sending
if(!$mail->Send()) {
    echo "Mailer Error: " . $mail->ErrorInfo;
} else {
   // maybe you should display a success message instead of redirecting!?
   header( 'Location: Index.html' );
   exit();
}
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11926
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: Problem with testing my email.php

Postby Chico Felipe » 31. May 2013 21:11

Thanks for getting back Altrea.

Alright, I created a new subfolder inside C:\xampp\htdocs\email\ and named it PHPMailer and moved the extracted content inside the same subfolder.

Now, if I understand your above code well I should only add the code above and change the email address and password and then save it as email.php (and delete the old email.php file). Is that correct???

Is it safe to add my gmail password here??? Would someone else be able to read it then?

Shouldn't the code above end with ?> or not?
Chico Felipe
 
Posts: 22
Joined: 31. May 2013 13:30
Operating System: Windows 7

Re: Problem with testing my email.php

Postby Altrea » 31. May 2013 21:28

Chico Felipe wrote:Now, if I understand your above code well I should only add the code above and change the email address and password and then save it as email.php (and delete the old email.php file). Is that correct???

correct :)

Chico Felipe wrote:Is it safe to add my gmail password here??? Would someone else be able to read it then?

It's a php file, so it will not be visible to anybody in preparsed state except of the users already have the read permission to open files on that server directly (you can see the processed output by viewing the content of the requested page in sourcecode view of the browser)
It is as dangerous than posting your credentials for sendmail in it's sendmail.ini file.

Chico Felipe wrote:Shouldn't the code above end with ?> or not?

If there is nothing more in the file you can get rid of the ?> at the end. That is best practise to prevent unwanted whitespace output
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11926
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: Problem with testing my email.php

Postby Chico Felipe » 31. May 2013 21:38

Ok. Thanks again for everything. You really helped me a lot. I will test this tomorrow because I am very exhausted now. This was too much for me as I am still beginner. My eyes hurt from staring at the screen and I can hardly think. Ha~ No worries, i'll be ok.

I will definitely inform you of the final outcome tomorrow or on Monday if you are going to follow this. If not, how can I get in touch with you?

Have a great weekend and hope this was useful for others who were reading!
Chico Felipe
 
Posts: 22
Joined: 31. May 2013 13:30
Operating System: Windows 7

Re: Problem with testing my email.php

Postby Chico Felipe » 31. May 2013 21:40

What if I want to use this web form in the future for somebody else who is not willing to share their email and password but still wants to receive the message directly inside their inbox? Can it be done without requiring password and only email address??? Gnite!
Chico Felipe
 
Posts: 22
Joined: 31. May 2013 13:30
Operating System: Windows 7

Re: Problem with testing my email.php

Postby Altrea » 31. May 2013 21:52

You are very welcome .

Chico Felipe wrote:This was too much for me as I am still beginner.

The only tricky part was to find out the correct parameters for gmail smtp.
The rest is not that complicated. If you have any questions left, just ask and i will do my best to explain it to you.
Doesn't matter, everybody has started at beginner rank :D

Chico Felipe wrote:I will definitely inform you of the final outcome tomorrow or on Monday if you are going to follow this.

I follow everything here.

Chico Felipe wrote:What if I want to use this web form in the future for somebody else who is not willing to share their email and password but still wants to receive the message directly inside their inbox? Can it be done without requiring password and only email address??? Gnite!

you mean you host the script but someone else should get the email? Well, then you have to authenticate to gmail still with your own credentials and simply can do this little change:
Code: Select all
//search for the line
$mail->AddAddress($mail->Username);

//replace it with
$mail->AddAddress('E-MAIL-ADDRESS@SOMEONE-ELSE.COM', 'SOMEONE ELSE NAME');

btw: sending someone an email without sharing his email address could be tricky too :lol:

Chico Felipe wrote:Have a great weekend and hope this was useful for others who were reading!

Thank you very much. Hope you can enjoy your weekend and that your home is okay -> thunderstorm :shock:
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11926
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: Problem with testing my email.php

Postby Chico Felipe » 01. June 2013 19:42

Hello again! I'm back to ones and zeros :)

I added the parameters for gmail smtp as you said above. Then I saved the whole code as PHP file and moved it to [url]C:\xampp\htdocs\email\[/url] (is that correct?) and I requested http://localhost/email/email.php but instead of getting my webform I immediately got the following message in my browsers window:

Notice: Undefined index: name in C:\xampp\htdocs\email\email.php on line 6
Notice: Undefined index: email in C:\xampp\htdocs\email\email.php on line 7
Notice: Undefined index: message in C:\xampp\htdocs\email\email.php on line 8
Invalid address: Message body empty Mailer Error: Message body empty


When I check my php code the lines 6, 7, and 8 are as follows:
Code: Select all
$name = $_REQUEST['name'] ;
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;


Not sure what to do next because my webform doesn't open. I thought my webform will open when I call http://localhost/email/email.php and then the user will fill out his/her name, email and message and the PHP will do the rest.

Altrea wrote: you mean you host the script but someone else should get the email?


Yes, that's what I meant. I added this part too in the above php code.

Altrea wrote: btw: sending someone an email without sharing his email address could be tricky too :lol:


Haha~ See, I was really tired last night! :)

Almost forgot to mention - I survived the thunderstorm yesterday and everything is fine. Thanks for your concern!
Chico Felipe
 
Posts: 22
Joined: 31. May 2013 13:30
Operating System: Windows 7

Re: Problem with testing my email.php

Postby Altrea » 01. June 2013 20:10

Chico Felipe wrote:I added the parameters for gmail smtp as you said above. Then I saved the whole code as PHP file and moved it to [url]C:\xampp\htdocs\email\[/url] (is that correct?)

Sure

Chico Felipe wrote:and I requested http://localhost/email/email.php but instead of getting my webform I immediately got the following message in my browsers window:

Notice: Undefined index: name in C:\xampp\htdocs\email\email.php on line 6
Notice: Undefined index: email in C:\xampp\htdocs\email\email.php on line 7
Notice: Undefined index: message in C:\xampp\htdocs\email\email.php on line 8
Invalid address: Message body empty Mailer Error: Message body empty


When I check my php code the lines 6, 7, and 8 are as follows:
Code: Select all
$name = $_REQUEST['name'] ;
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;


Not sure what to do next because my webform doesn't open.

Of course not. The email.php doesn't contain any form. I thought i have orientated that on the code examples by you from the first post here.
You seems to have an extra page for the form. The email.php expects that it is referenced by an forms action attribute.
You can integrate the form into that email.php file too, that is the well known "self referencing form".

The script is just an basic example to keep it simple. You should do some validation before you send an email, especially if the expected fields that have to be filled are really filled.

Chico Felipe wrote:Almost forgot to mention - I survived the thunderstorm yesterday and everything is fine. Thanks for your concern!

I'm glad to read that :D
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11926
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

PreviousNext

Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 137 guests