Reputation: 11
I know you've got this topic lot of times. The thing I spent all the week reading turorials from this, and other websites. I want to make the mail function to work, but it does'nt really want. My operation system is windows 8. I use wamp as apache,and I tried all the ways to send emails through smtp. I tried gmail and yahoo. I modified the sendmail.ini and php.ini hundred times. I tried phpmailer class, what worked for a while, but when I tried to implement in a contact form, it stoped to work.Now it's not working at all :). I tried the stunnel stuff as well, nothing really happened. Now I just try to sort out a simple mail function to send an email, as first step.The page is blank. It doesn't really give any error, but I don't get the email. These are my settings at the moment.
php.ini file:
[mail function]
; For Win32 only.
SMTP =localhost
smtp_port =25
; For Win32 only.
; http://php.net/sendmail-from
sendmail_from [email protected]
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
sendmail_path ="\""c:\wamp\sendmail\sendmail.exe\" -t"
sendmail.ini file:
smtp_server=smtp.gmail.com
; smtp port (normally 25)
smtp_port=587
auth_password=password
I put port number 587, this is what I saw on the last topic I read. I hoped it helps. I tried 25 and 465 as well before. My question is maybe sounds stupid. IS IT POSSIBLE , THAT MY SMTP CONNECTION CAN BE AFFECTED, BY THE OPERATION SYSTEM OR THE FIREWALL OF THE PC?? I just started to learn know php, and I cannot go forward, till I don't solve this issue. Thank you
Upvotes: 1
Views: 1042
Reputation: 124
Have yout tried using PHPMailer? Simply download it from https://github.com/PHPMailer/PHPMailer and include it in your code like:
include ("PHPMailer/class.phpmailer.php"); include ("PHPMailer/class.smtp.php"); $subject = "your mail subject"; $body = "your mail body"; $headers = "From: " . $emailfrom; // Send mail $mail = new PHPMailer(); $mail->IsSMTP(); // telling the class to use SMTP // SMTP Configuration $mail->SMTPAuth = true; // enable SMTP authentication $mail->Host = "smtp.gmail.com"; // SMTP server $mail->Username = "[email protected]"; $mail->Password = "your email password"; //$mail->Port = 465; // optional if you don't want to use the default $mail->From = "[email protected]"; $mail->FromName = "name of sender"; $mail->Subject = $subject; $mail->MsgHTML($body); // Add as many as you want $mail->AddAddress($emailto); // If you want to attach a file, relative path to it //$mail->AddAttachment("images/phpmailer.gif"); // attachment $response= NULL; if(!$mail->Send()) { $response = "Mailer Error: " . $mail->ErrorInfo; } else { $response = "Message sent!"; }
Upvotes: 2