0

I'm new to phpmailer and I tried to follow their example. I'm using php mail() function to send emails and I'm getting an error:

"Invalid address: $toYou must provide at least one recipient email address. Mailer Error: You must provide at least one recipient email address."

What email address is valid then? I've tried three and I still get the same error. Thanks

2
Contributors
10
Replies
16
Views
4 Years
Discussion Span
Last Post by tscina
Featured Replies
  • **@tscina** This is wrong: `$mail->Host = 'ssl://smtp.gmail.com';` It just should be this: `$mail->Host = "smtp.gmail.com"; ` Read More

0

@tscina

What email address is valid then? I've tried three and I still get the same error. Thanks

The error means here:

$mail->AddAddress('valid@tscina.com', 'recipient email');

Since you didn't provide the code. I assume got that PHPMailer from Worxware.

Here is a code that will solve that issue

http://phpmailer.worxware.com/index.php?pg=exampleamail

Edited by LastMitch: grammer

0

I'm using this code

$mail             = new PHPMailer();

$mail->IsSMTP();
$mail->Host = 'ssl://smtp.gmail.com';
$mail->SMTPAuth      = true;
$mail->SMTPKeepAlive = true;
$mail->Port          = 465;  
$mail->Username      = "my@gmail.com";
$mail->Password      = "password";
$mail->SetFrom('my@email.com', 'First Last');
$to = "my@gmail.com";
$mail->AddAddress('$to',"First Last");
$mail->Subject = "Test Mail";
$message = "messages go here";
$mail->MsgHTML($message);
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
}else{
echo "An e-mail was sent to $to with the subject: $subject";;}

I did put valid mails in the emails. I'm not familiar with smtp settings. I'm still trying to look around

Edited by tscina

0

I've changed the ''s to ""s and now i get this message
SMTP Error: Could not connect to SMTP host. Mailer Error: SMTP Error: Could not connect to SMTP host.
BTW this script is offline and I just want to test my script on how it looks like. Thanks for the help btw.

3

@tscina

This is wrong:

$mail->Host = 'ssl://smtp.gmail.com';

It just should be this:

$mail->Host = "smtp.gmail.com";

Votes + Comments
To Rectify what some retard did to LastMitch
0
$mail             = new PHPMailer();

$mail->IsSMTP();
$mail->SMTPDebug = 0;
$mail->SMTPAuth      = true;
$mail->SMTPKeepAlive = true;
$mail->SMTPSecure = 'ssl';
$mail->Host = "smtp.gmail.com";
$mail->Port          = 465; 
$mail->Username      = GUSER;
$mail->Password      = GPWD;
$mail->SetFrom("my@gmail.com", 'First Last');
$mail->Subject = "Test Mail";

$to = "my@yahoo.com";
$mail->AddAddress($to);

This is my new code with the error SMTP Error: Could not connect to SMTP host. Mailer Error: SMTP Error: Could not connect to SMTP host.

0

BTW this script is offline and I just want to test my script on how it looks like. Thanks for the help btw.

You have to run this on a host server not offline!

This is my new code with the error SMTP Error: Could not connect to SMTP host. Mailer Error: SMTP Error: Could not connect to SMTP host.

Did you restarted the system then run the script again?

Does host server accept SMTP meaning do let you used this?

Did you enable: ssl?

Read this about gmail:

Did you enable SSL3 for the SMTP4 server?

http://support.google.com/mail/bin/answer.py?hl=en&answer=78775

Edited by LastMitch: grammer

0

is there any way i could test run the script without uploading to my host?

0

turns out i needed to change something with php.ini.

Now I've got a new error

SMTP -> ERROR: Failed to connect to server: Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP? (1743284271) 

Any ideas?

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.