0

contact_us.php

<h2>Contact Us</h2>
<br /><br />
      
<form action="send_email.php" method="POST">      
<table border="0" cellpadding="2">
<tr>	
    <td>Nama Lengkap: </td>
 	<td><input name="nama" type="text" value="" size="30" /></td>
</tr>
<tr>    
    <td>E-mail: </td>
	<td><input name="email" type="text" value="" size="20" /></td>
</tr>    
<tr>
	<td>Nomor Telepon: </td>
    <td><input name="telp" type="text" value="" size="15" /></td>
</tr>    
<tr>
	<td>Pilih Subjek : </td>
    <td><select name="subjek"><option value=Additive selected>Additive</option>
    <option value=Air Freshener>Air Freshener</option>
    <option value=Lainnya>Lainnya</option>    
    </td>
</tr>
<tr>
	<td>Pesan Anda  : </td>
	<td><textarea name="comments" cols=30 rows=6></textarea></td>
</tr>
<tr>
	<td></td>
    <td><input name="kirim_pesan" type="submit" value="Kirim Pesan" /> 
</table>
</form>      
</div>

send_mail.php

<?php

//
$nama = isset($_GET['nama']) ? $_GET['nama'] : '';
$email = isset($_GET['email']) ? $_GET['email'] : '';
$telepon = isset($_GET['telepon']) ? $_GET['telepon'] : '';
$subjek = isset($_GET['subjek']) ? $_GET['subjek'] : '';	  
$comments = isset($_GET['comments']) ? $_GET['comments'] : '';
	  
//$nama = $_GET["nama"];
//$email = $_GET["email"];
//$telepon = $_GET["telepon"];
//$subjek = $_GET["subjek"];
//$comments = $_GET["comments"];
?> 
 
<?php
// using htmlentities

$newnama= htmlspecialchars($nama, ENT_QUOTES);
$newemail = htmlspecialchars($email, ENT_QUOTES);
$telepon = htmlspecialchars($telepon, ENT_QUOTES);
$newsubjek = htmlspecialchars($subjek, ENT_QUOTES);
$newcomments = htmlspecialchars($comments, ENT_QUOTES); 
 
?> 
 
<h1>Demo Send Email</h1>
<hr>
Kepada : Kamu
Subject : <?php echo $subjek; ?>
Pesan : <?php echo $comments; ?>
Dari : <?php echo $nama; ?>
<br />
<?php
ini_set("SMTP", "172.16.1.1");
ini_set("sendmail_from", "$email");
mail("david_yg20@yahoo.com", "$subjek", "$comments");
?>

Telah dilakukan!

Demo Send Email

--------------------------------------------------------------------------------
Kepada : Kamu Subject : Pesan : Dari :

Warning: mail() [function.mail]: Failed to connect to mailserver at "172.16.1.1" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\xampp\htdocs\Masterlink\cgoods\send_email.php on line 47
Telah dilakukan!

The above error appears after I press "Kirim Pesan".

Also, I do not receive the e-mail I suppose to receive, also the Subject, Pesan, and Dari are empty.

3
Contributors
28
Replies
29
Views
5 Years
Discussion Span
Last Post by davy_yg
0

Use $_POST, not $_GET.

Are you sure your mail server allows you to connect, or does it need authentication ?

0

Well, I just activated my mail server. Now, I receive this message:

Demo Send Email

--------------------------------------------------------------------------------
Kepada : Kamu Subject : Additive Pesan : Pesan Dari : David

Warning: mail() [function.mail]: SMTP server response: 551 User not local. We don't relay in C:\xampp\htdocs\Masterlink\cgoods\send_email.php on line 47
Telah dilakukan!

I do not receive the e-mail yet. I change the ini_set("SMTP", "localhost");

How to check whether it requires authentication or not.

0

The error message says so (no relay). You need to use PHPMailer for example. mail() does not support authentication. There are plenty examples in this forum about it.

0

I modify the code:

<?php
require("PHPMailer5\class.phpmailer.php");

$mail = new PHPMailer();

$mail->IsSMTP();
$mail->Host = "plus.smtp.mail.yahoo.com";
$mail->SMTPAuth = false;
$mail->Username = 'david_yg20@yahoo.com';
$mail->Password = '****'; 
$mail->From="mailer@example.com";
$mail->FromName="My site's mailer";
$mail->Sender="mailer@example.com";
$mail->AddReplyTo("replies@example.com", "Replies for my site");
$mail->AddAddress("plasteezy@yahoo.com");
//$mail->Subject = $subject;
$mail->IsHTML(true);#$mail->AddAttachment('http://www.branddesignexpress.com/images/homepage_mainimage.jpg', 'homepage_mainimage.jpg');
$mail->AddEmbeddedImage('homepage_mainimage.jpg', 'logoimg', 'homepage_mainimage.jpg'); // attach file logo.jpg, and later link to it using identfier //logoimg$mail->Body = $msg;$mail->AltBody="This is text only alternative body.";
if(!$mail->Send()){   echo "Error sending: " . $mail->ErrorInfo;;
?>
}else{   echo "Letter is sent";}

Telah dilakukan!

</body>
</html>

I receive this error:

Demo Send Email

--------------------------------------------------------------------------------
Kepada : Kamu Subject : AdditivePesan : PesanDari : David
Error sending: Message body empty Telah dilakukan!

Why is it ?

1


--------------------------------------------------------------------------------
Kepada : Kamu Subject : AdditivePesan : PesanDari : David
Error sending: Message body empty Telah dilakukan!

Why is it ?

Mh! You have to learn reading error messages!

0

How to set the message body. I have try to add the following codes:

$mail->body="This is the message body";

// or

$mail->body=$newcomments;

The same error still appears.

0

How to set the message body. I have try to add the following codes:

$mail->body="This is the message body";

// or

$mail->body=$newcomments;

The same error still appears.

$mail->MsgHTML

Check this thread and this tutorial

Edited by Stefano Mtangoo: n/a

0

Kepada : Kamu Subject : AdditivePesan : PesanDari : Davy
SMTP Error: Could not authenticate. Error sending: SMTP Error: Could not authenticate.
SMTP server error:

Telah dilakukan!

<?php
require("PHPMailer5\class.phpmailer.php");

$mail = new PHPMailer();

$mail->IsSMTP();
$mail->Host = "plus.smtp.mail.yahoo.com";
$mail->Port = 25; 

$mail->SMTPAuth = true;
$mail->Username = 'david_yg20@yahoo.com';
$mail->Password = '****'; 
$mail->From="mailer@example.com";
$mail->FromName="My site's mailer";
//$mail->body="This is the message body";
$mail->Body=$newcomments;
$mail->Sender="mailer@example.com";
$mail->AddReplyTo("replies@example.com", "Replies for my site");
$mail->AddAddress("plasteezy@yahoo.com");
//$mail->Subject = $subject;
$mail->IsHTML(true);#$mail->AddAttachment('http://www.branddesignexpress.com/images/homepage_mainimage.jpg', 'homepage_mainimage.jpg');
$mail->AddEmbeddedImage('homepage_mainimage.jpg', 'logoimg', 'homepage_mainimage.jpg'); // attach file logo.jpg, and later link to it using identfier //logoimg$mail->Body = $msg;$mail->AltBody="This is text only alternative body.";
if(!$mail->Send()){   echo "Error sending: " . $mail->ErrorInfo;;

}else{   echo "Letter is sent";}
?>
Telah dilakukan!

</body>
</html>
0

The message is clear, Authentication failed! Are you sure your smtp details are ok?
May be you contact yahoo for this (since it seems you have bought plus package) else try to remove the plus and just leave smtp.mail.yahoo.com

0

http://help.yahoo.com/l/us/yahoo/mail/yahoomail/mailplus/pop/pop-14.html

Very good link and I was right, that plus is not needed!

Outgoing mail server (SMTP) settings

SMTP server: smtp.mail.yahoo.com
Use SSL
Port: 465
Use authentication
Account Name/Login Name: Your Yahoo! Mail ID (your email address without the "@domain.com", for example, “jo.bloggs”)
Email Address: Your Yahoo! Mail address (for example, jo.bloggs@yahoo.com)
Password: Your Yahoo! Mail password

0
$mail = new PHPMailer();

$mail->IsSMTP();
$mail->Host = "smtp.mail.yahoo.com";
$mail->Port = 465; 

$mail->SMTPAuth = true;
$mail->Username = 'myemail@yahoo.com';
$mail->Password = 'mypassword'; 
$mail->From="mailer@example.com";
$mail->FromName="My site's mailer";
//$mail->body="This is the message body";
$mail->Body=$newcomments;
$mail->Sender="mailer@example.com";
$mail->AddReplyTo("replies@example.com", "Replies for my site");
$mail->AddAddress("plasteezy@yahoo.com");
//$mail->Subject = $subject;
$mail->IsHTML(true);#$mail->AddAttachment('http://www.branddesignexpress.com/images/homepage_mainimage.jpg', 'homepage_mainimage.jpg');
$mail->AddEmbeddedImage('homepage_mainimage.jpg', 'logoimg', 'homepage_mainimage.jpg'); // attach file logo.jpg, and later link to it using identfier //logoimg$mail->Body = $msg;$mail->AltBody="This is text only alternative body.";
if(!$mail->Send()){   echo "Error sending: " . $mail->ErrorInfo;;

}else{   echo "Letter is sent";}
?>
Telah dilakukan!

Warning: fputs() expects parameter 1 to be resource, integer given in C:\xampp\htdocs\Masterlink\cgoods\PHPMailer5\class.smtp.php on line 215
SMTP Error: Could not authenticate. Error sending: SMTP Error: Could not authenticate.Telah dilakukan!

I wonder what I've done wrong. I've enter e-mail, password, smtp correctly.

0

send_email.php

<?php
require("PHPMailer5\class.phpmailer.php");

$mail = new PHPMailer();

$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'SSL';
$mail->Host = 'smtp.mail.yahoo.com';
$mail->Port = 465; 
$mail->Username = 'david_yg@yahoo.com';
$mail->Password = '*********'; 

$mail->From='david_yg@yahoo.com';
$mail->FromName="My site's mailer";
$mail->Body = $newcomments;
$mail->Sender='david_yg@yahoo.com';
$mail->AddReplyTo("replies@example.com", "Replies for my site");
$mail->AddAddress("plasteezy@yahoo.com");
//$mail->Subject = $subject;
$mail->IsHTML(true);#$mail->AddAttachment('http://www.branddesignexpress.com/images/homepage_mainimage.jpg', 'homepage_mainimage.jpg');
$mail->AddEmbeddedImage('homepage_mainimage.jpg', 'logoimg', 'homepage_mainimage.jpg'); // attach file logo.jpg, and later link to it using identfier //logoimg$mail->Body = $msg;$mail->AltBody="This is text only alternative body.";
if(!$mail->Send()){   echo "Error sending: " . $mail->ErrorInfo;

}else{   echo "Letter is sent";}
?>

It still shows me the same errors.

0

Well, I change the port to 25. Letter is sent. but when I check my e-mail I do not see the e-mail that I suppose to receive.

Why is it ?

0

it's not in my junk mail either. It seems like I receiving nothing.

0

I try another account and receive this error:

SMTP server error: 5.7.0 Must issue a STARTTLS command first

0

I am using version 5. I've tried to reinstalled the PHPMailer but it makes no difference.

earlier I try sending it to my hotmail account:

SMTP: smtp.live.com
Port: 25
Secure: SSL

I wonder why? I also, already try to resend to my yahoo account. Where the from suppose to be from ?

I match Username, From, and sender. Is it okay ?

0

I found a blog docummenting changes in hotmail Auth

require_once('../class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded

$mail = new PHPMailer();

$body = file_get_contents('contents.html');
$body = eregi_replace("[\]",'',$body);

$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "mail.yourdomain.com"; // SMTP server
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "tls"; // sets the prefix to the servier
$mail->Host = "smtp.live.com"; // sets HOTMAIL as the SMTP server
$mail->Port = 25; // alternate is "26" - set the SMTP port for the HOTMAIL server
$mail->Username = "yourusername@hotmail.com"; // HOTMAIL username
$mail->Password = "yourpassword"; // HOTMAIL password

$mail->SetFrom('name@yourdomain.com', 'First Last');

$mail->AddReplyTo("name@yourdomain.com","First Last");

$mail->Subject = "PHPMailer Test Subject via smtp (Hotmail), basic";

$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test

$mail->MsgHTML($body);

$address = "whoto@otherdomain.com";
$mail->AddAddress($address, "John Doe");

$mail->AddAttachment("images/phpmailer.gif"); // attachment
$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment

if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
0
Warning: stream_socket_enable_crypto() [streams.crypto]: this stream does not support SSL/crypto in C:\xampp\htdocs\Masterlink\cgoods\PHPMailer5\class.smtp.php on line 197
Language string failed to load: tls Error sending: Language string failed to load: tls
SMTP server error:

That's from my hotmail account.

0

It seems ssl already enable.

There is no # mark in LoadModule ssl_module modules/mod_ssl.so (httpd.conf).

I add:

$mail->SMTPSecure = 'tls';
$mail->SMTPSecure = 'ssl';

and now, I have:

SMTP Error: Could not connect to SMTP host. Error sending: SMTP Error: Could not connect to SMTP host.

$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'tls';
$mail->SMTPSecure = 'ssl';
$mail->Host = 'smtp.live.com';
$mail->Port = 25; 
$mail->Username = 'davy_yg@hotmail.com';
$mail->Password = '****'; 

$mail->From='davy_yg@hotmail.com';
$mail->FromName="My site's mailer";
$mail->Body = $newcomments;
$mail->Sender='davy_yg@hotmail.com';
$mail->AddReplyTo("replies@example.com", "Replies for my site");
$mail->AddAddress("plasteezy@yahoo.com");
//$mail->Subject = $subject;
$mail->IsHTML(true);#$mail->AddAttachment('http://www.branddesignexpress.com/images/homepage_mainimage.jpg', 'homepage_mainimage.jpg');
$mail->AddEmbeddedImage('homepage_mainimage.jpg', 'logoimg', 'homepage_mainimage.jpg'); // attach file logo.jpg, and later link to it using identfier //logoimg$mail->Body = $msg;$mail->AltBody="This is text only alternative body.";
if(!$mail->Send()){   echo "Error sending: " . $mail->ErrorInfo;

}else{   echo "Letter is sent";}
?>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.