Jump to content

[SOLVED] simple email from local machine using gmail smtp? not working


sayedsohail

Recommended Posts

Hi everyone,

 

I am developing an application using php on windows xp machine, which connects to my email hosting company using broadband with outlook express uploads downoads works fine.

 

Than I thought why not generate email directly from php pages and send email for demo purpose.

 

Unfortunately its not working.

 

The steps i followed.

 

1. change php.ini (infact i tried my email hosting server aswell but none of this works)

 

SMTP = smtp.gmail.com
smtp_port = 465
; For Win32 only.
sendmail_from = tislog@gmail.com

2. Try to test a script

 

 

<? 
$to = "sayedsalmansohail@yahoo.com";  
$from = "tislog@gmail.com";  
$result = mail($to,"Test message","This is my test message");  

echo $result;   
?>

 

3.  When i run the code, the page is keep on running and shows no error.

I don't know how to pass the smtp email account password.  can anyone help please?

Link to comment
Share on other sites

Sorry, i just got a last question, here I am trying to upload files from my email form, which works fine for uploading jpeg/gif format files, but i wish upload only pdf, htm or html files.  Here is my code:

 

Form:

 

<!doctype html public "-//w3c//dtd html 3.2//en">
<html>
<head>
<title>Multiple image upload script</title>
</head>
<body >
<?
$max_no_img=4;  // Maximum number of images value to be set here
echo "<form method=post action=attach.php enctype='multipart/form-data'>";
echo "<table border='0' width='400' cellspacing='0' cellpadding='0' align=center>";
for($i=1; $i<=$max_no_img; $i++){
echo "<tr><td>Images $i</td><td>
<input type=file name='images[]' ></td></tr>";
}
echo "<tr><td colspan=2 align=center><input type=submit value='Send'></td></tr>"; 

echo "</form> </table>";
?>
<center><a href='http://localhost'>Back to Main Menu</a></center> 
</body>
</html>

Function which is checking the type of file, this is the bit i need some help, to allow .htm, .html, jpeg, pdf and doc files to upload.

 

Attach.php

 

checkType();


//------Check TYPE------\\	

function checkType() {	
while(list($key,$value) = each($_FILES[images][type])){
	strtolower($value);
	if($value != "image/jpeg" AND  $value != "image/pjpeg" AND $value != "") {


		exit('Sorry , current format is <b>'.($value).'</b> ,only Jpeg or jpg are allowed.') ;
	}
}

checkSize();

}

Link to comment
Share on other sites

you need to change this

 

 

 

if($value != "image/jpeg" AND  $value != "image/pjpeg" AND $value != "") {

 

to

 

if($value != "text/html" AND  $value != "application/pdf" AND $value != "") {

 

oh and the message

 

exit('Sorry , current format is <b>'.($value).'</b> ,only html or pdf are allowed') ;

 

EDIT: also please don't PM me the post... unless theirs private data and you trust me and i request it

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.