Jump to content

PHP Mailer


PRodgers4284

Recommended Posts

Im trying out a phpmailer example but i cant seem to get it to send the email, im getting an error about the from address that it is being sent.

 

Im getting the followng error "Message was not sent.Mailer error: The following From address failed: *************@yahoo.com"

 

I havent modified the phpmailer.php as im not sure what i need to change, has anyone got any ideas?

 

 

<?php 
require("class.phpmailer.php"); 
$mail = new PHPMailer(); 
$mail->IsSMTP(); // telling the class to use SMTP 
$mail->Host = "smtp.yahoo.com"; // SMTP server 
$mail->Password = '*********'; 
$mail->From = "*************@yahoo.com"; 
$mail->AddAddress("************@yahoo.co.uk"); 
$mail->Subject = "First PHPMailer Message"; 
$mail->Body = "Hi! \n\n This is my first e-mail sent through PHPMailer."; 
$mail->WordWrap = 50; 

if(!$mail->Send()) 
{ 
   echo 'Message was not sent.'; 
   echo 'Mailer error: ' . $mail->ErrorInfo; 
} 
else 
{ 
   echo 'Message has been sent.'; 
} 
?> 

Link to comment
https://forums.phpfreaks.com/topic/92456-php-mailer/
Share on other sites

Use your own mail server.

 

revraz i dont have access to my own mail server, i decided to use googlemail instead, been reading up and it there sames to be problems with yahoo.

 

Im getting an error now saying:

 

Warning: fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.gmail.com:465 (Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?) in C:\wamp\www\PHPMailer_v2.0.0\class.smtp.php on line 122

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

Link to comment
https://forums.phpfreaks.com/topic/92456-php-mailer/#findComment-473703
Share on other sites

You don't have access to your own mail server? You should be able to use whatever SMTP server is set up on your hosting server. I believe you can also set PHPMailer to use the mail function as well.

 

I have decided to use gmail instead of yahoo, have been reading up and there seems to be problems with using yahoo.

 

Im using the following script for gmail but im getting the error, how do i enable the "ssl"?

 

Warning: fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.gmail.com:465 (Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?) in C:\wamp\www\PHPMailer_v2.0.0\class.smtp.php on line 122

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

 

<?php

// example on using PHPMailer with GMAIL 

include("class.phpmailer.php");
include("class.smtp.php");

$mail=new PHPMailer();

$mail->IsSMTP();
$mail->SMTPAuth   = true;                  // enable SMTP authentication
$mail->SMTPSecure = "ssl";                 // sets the prefix to the servier
$mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
$mail->Port       = 465;                   // set the SMTP port 

$mail->Username   = "*************@gmail.com";  // GMAIL username
$mail->Password   = "*********";            // GMAIL password

$mail->From       = "*************@gmail.com";
$mail->FromName   = "Webmaster";
$mail->Subject    = "This is the subject";
$mail->Body       = "Hi,<br>This is the HTML BODY<br>";                      //HTML Body
$mail->AltBody    = "This is the body when user views in plain text format"; //Text Body

$mail->WordWrap   = 50; // set word wrap

$mail->AddAddress("*************@gmail.com","First Last");
$mail->AddReplyTo("*************@gmail.com","Webmaster");

$mail->IsHTML(true); // send as HTML

if(!$mail->Send()) {
  echo "Mailer Error: " . $mail->ErrorInfo;
} else {
  echo "Message has been sent";
}

?>

 

Link to comment
https://forums.phpfreaks.com/topic/92456-php-mailer/#findComment-473726
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.