PhpMailer

Fxxxx

Utente Attivo
17 Set 2011
63
0
0
Ciao ho creato un form in html e ho collegato una pagina php; eccola qui:

PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento senza titolo</title>
</head>

<body>
<?php
$speech=$_POST["speech"];
$destinatario=$_POST["email"];
$oggetto="Soundy";


require("class.phpmailer.php");

$mail = new PHPMailer();

$mail->IsSMTP();  // telling the class to use SMTP
$mail->Host     = "smtp.gmail.com"; // SMTP server
$mail->Username = "[email protected]"; // SMTP username
$mail->Password = "password"; // SMTP password
$mail->SMTPAuth = true;//Abilito l'autenticazione SMTP
$mail->Port = 465;

$mail->From     = "[email protected]";
$mail->AddAddress("$destinatario");

$mail->Subject  = "Soundy";
$mail->Body     = "$speech";
$mail->WordWrap = 50;

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

Quando provo il sito (naturalmente su un server) mi dice: Message was not sent.Mailer error: SMTP Error: Could not connect to SMTP host.
Che errore ho commesso ?
Il funzionamento del sito è: scrivo il testo: speech e scrivo l'indirizzo email e clicco invia e il testo viene inviato alla casella email

Come mai non funziona ?
 
Ultima modifica di un moderatore:

Fxxxx

Utente Attivo
17 Set 2011
63
0
0
Ok
ho usato questo script
require_once '/path/of/swiftmailer/lib/swift_required.php';

PHP:
$mymail = Swift_Message::newInstance()  
  
  ->setSubject('Subject of this mail')  
  
  ->setFrom(array('[email protected]' => 'My Name'))  
  
  ->setTo(array('[email protected]' => 'Your Name'))  
  
  ->setBody('This is the message!');  
  
$mysmtp = Swift_SmtpTransport::newInstance('smtp.mymail.com', 25)  
  
  ->setUsername('myusername')  
  
  ->setPassword('mypassword');  
  
$mailer = Swift_Mailer::newInstance($mysmtp);  
  
$bool = $mailer->send($mailer);

Ma come faccio con l'autentificazione smtp ?
Mi potete dire cosa scrivere ?
 
Ultima modifica di un moderatore:
Discussioni simili
Autore Titolo Forum Risposte Data
G phpmailer e php 8.1 con estensione mysqli PHP 6
E Hosting e phpmailer PHP 0
E PHPMailer PHP 4
D PHPMailer con account gmail PHP 14
I PHPMailer non funziona PHP 13
I Guida/Tutorial configurare PHPMailer per inviare mails tramite contact form? PHP 2
A PHPMAILER e UMLAUTS (lettere tedesche äüäöß) PHP 2
G PHPMailer: SMTP error Gmail PHP 8
M Come usare la nuova versione di phpmailer? PHP 2
P [PHPmailer] SMTP Aruba.. problemi PHP 8
G Invio Mail con PHPMailer, problemi SMTP PHP 7
V PHPMailer PHP 11
V PHPmailer allegato PHP 0
P problemi invio email con phpmailer PHP 47
P phpmailer PHP 0
localhost.nicola File log erroe con phpmailer PHP 3
A problema phpmailer PHP 32
L invio smtp con phpmailer - problema invia due volte la email allo stesso utente PHP 0
O PhpMailer, Composer e Netbeans PHP 1
M Come inviare due mail diverse con phpmailer PHP 6
Z email phpmailer non arrivano PHP 0
B Invio email multiple PHPMAILER PHP 3
L Problema phpmailer,jquery e smtp PHP 1
P Problemi visualizzazione html con phpmailer PHP 6
P phpmailer e file_get_contents PHP 1
P Phpmailer ed wind-infostrada PHP 20
felino PHPMailer: Indirizzo IP e Immagine PHP 6
lsnight Phpmailer per principianti PHP 7
K form con phpmailer PHP 18
P Invio multiplo mail con phpmailer PHP 5
L problema classe phpmailer con la mia classe clsMail PHP 2
G problema con phpmailer 5.2.1 PHP 1
minatore Phpmailer PHP 6
M phpmailer multiplo in più pagine di un sito PHP 5
N PhpMailer SELECT e OPTION PHP 190
N PhpMailer e salvataggio allegato sul server PHP 11
R Phpmailer SMTP PHP 23
A problema con phpmailer PHP 10
metalgemini PHPmailer non arriva allegato PHP 10
piccino PHPMailer: inserire allegato PHP 5
E Invio email (era: phpmailer) PHP 52
F Phpmailer e l'indirizzo del mittente PHP 3
borgo italia phpmailer?? PHP 7
C phpmailer PHP 7
emanuelevt phpmailer e altervista PHP 3
catellostefano Problema con la classe class.phpmailer.php PHP 5
SolidSnake4 PHPmailer errore PHP 4
A classe PHPMailer e mail di Libero PHP 1
S php mail vs phpmailer PHP 0
T Problemi phpmailer x invio ad indirizzi di libero. Aiutatemi! PHP 14

Discussioni simili