Nel caso si debba utilizzare un account email StarterMail per l'autenticazione SMTP su un servizio esterno, è consigliabile farlo usando i seguenti parametri:

username:     user@example.com         (deve essere un account completo, non un forward)         

password:      la password dell'account utilizzato

host:                156.unihost.it             

crittografia:      STARTTLS

porta:              587

 

NOTA: anche per questioni di sicurezza è consigliabile a questo scopo utilizzare un account appositamente creato per questo servizio, e non un account già esistente ed utilizzato normalmente per altri scopi! 

 

Forniamo di seguito un esempio di utilizzo con la libreria PHPMailer:

<?php
// Import PHPMailer classes into the global namespace
// These must be at the top of your script, not inside a function
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;

// Load Composer's autoloader
require 'vendor/autoload.php';

// Instantiation and passing `true` enables exceptions
$mail = new PHPMailer(true);

try {
    //Server settings
    $mail->SMTPDebug = SMTP::DEBUG_SERVER;                      // Enable verbose debug output
    $mail->isSMTP();                                            // Send using SMTP
    $mail->Host       = '156.unihost.it';                       // Set the SMTP server to send through
    $mail->SMTPAuth   = true;                                   // Enable SMTP authentication
    $mail->Username   = 'user@example.com';                     // SMTP username
    $mail->Password   = 'secret';                               // SMTP password
    $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;         // Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` encouraged
    $mail->Port       = 587;                                    // TCP port to connect to, use 465 for `PHPMailer::ENCRYPTION_SMTPS` above

    //Recipients
    $mail->setFrom('from@example.com', 'Mailer');
    $mail->addAddress('joe@example.net', 'Joe User');     // Add a recipient
    $mail->addAddress('ellen@example.com');               // Name is optional
    $mail->addReplyTo('info@example.com', 'Information');
    $mail->addCC('cc@example.com');
    $mail->addBCC('bcc@example.com');

    // Attachments
    $mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
    $mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name

    // Content
    $mail->isHTML(true);                                  // Set email format to HTML
    $mail->Subject = 'Here is the subject';
    $mail->Body    = 'This is the HTML message body <b>in bold!</b>';
    $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

    $mail->send();
    echo 'Message has been sent';
} catch (Exception $e) {
    echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}

 

 

  • StarterMail 2
  • 48 Users Found This Useful
Was this answer helpful?

Related Articles

  StarterMail 2 - tracciamento delle e-mail

Vi sono diverse situazioni in cui può esser utile verificare i dettagli di invio o ricezione di...

 StarterMail 2 - How to Configure iPhone's "Mail" App

To add a StarterMail email account into your iPhone's "Mail" app: Open the "Settings" app »...

 StarterMail 2 - come controllare lo spazio utilizzato e disponibile di una casella

Per controllare lo spazio effettivamente utilizzato e quello ancora disponibile per gli archivi...

 How to Recover Email Header in Webmail

To recover the email header in StarterMail webmail, follow the below steps: Login to webmail...

 StarterMail - protezione anti brute force

Tra le varie protezioni di sicurezza del sistema StarterMail, ve ne è uno anche contro i...