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