2015-03-02 16 views
8

Desidero inviare posta tramite posta php sul servizio Amazon SES, nell'utilizzo di PHP Mail, ma non sono in grado di inviare l'invio. Ho già verificato il mio email_id. Sto usando questo tutorial come riferimento http://www.codeproject.com/Articles/786596/How-to-Use-Amazon-SES-to-Send-Email-from-PHP. Ma non sta inviando posta dai servizi Amazon SES, per favore dimmi dove mi sbaglio? Precedentemente stavo usando lo stesso id per inviare mail dal localserver XAMPP. Stava funzionando.Come inviare la posta tramite posta php sul servizio Amazon SES?

sendMail.php

<?php > 
function Send_Mail($to,$subject,$body) 
{ 
    require 'class.phpmailer.php'; 
    $from = "Senders_Email_Address"; 
    $mail = new PHPMailer(); 
    $mail->IsSMTP(true); // SMTP 
    $mail->SMTPAuth = true; // SMTP authentication 
    $mail->Mailer = "smtp"; 
    $mail->Host= "tls://email-smtp.us-east.amazonaws.com"; // Amazon SES 
    $mail->Port = 465; // SMTP Port 
    $mail->Username = "Senders_Email_Address"; // SMTP Username 
    $mail->Password = "MyPassword"; // SMTP Password 
    $mail->SetFrom($from, 'From Name'); 
    $mail->AddReplyTo($from,'Senders_Email_Address'); 
    $mail->Subject = $subject; 
    $mail->MsgHTML($body); 
    $address = $to; 
    $mail->AddAddress($address, $to); 
    if(!$mail->Send()) 
     return false; 
    else 
     return true; 
} 
?> 

index.php

<html> 
<body>  
<h1>Welcome to my home page!</h1> 
<p>Some text.</p> 
<p>Some more text.</p> 
<?php 
require 'sendMail.php'; 
$to = "Senders_Email_Address"; 
$subject = "Test Mail Subject"; 
$body = "Hi<br/>Test Mail<br/>Amazon SES"; // HTML tags 
Send_Mail($to,$subject,$body); 
?> 

</body> 
</html> 

sendMail.php, class.phpmailer.php, class.smtp.php e index.php sono in la stessa directory.

risposta

6

Neelabh, ti manca qualcosa. prova a seguire:

<?php > 
function Send_Mail($to,$subject,$body) 
{ 
require 'class.phpmailer.php'; 
$from = "verified_email address"; 
$mail = new PHPMailer(); 
$mail->IsSMTP(true); // SMTP 
$mail->SMTPAuth = true; // SMTP authentication 
$mail->Mailer = "smtp"; 
$mail->Host= "tls://email-smtp.us-east.amazonaws.com"; // Amazon SES 
$mail->Port = 465; // SMTP Port 
$mail->Username = "Your_SMTP_Username 
"; // SMTP Username 
$mail->Password = "SMTP_Password"; // SMTP Password 
$mail->SetFrom($from, 'From Name'); 
$mail->AddReplyTo($from,'yourdomain.com or verified email address'); 
$mail->Subject = $subject; 
$mail->MsgHTML($body); 
$address = $to; 
$mail->AddAddress($address, $to); 

if(!$mail->Send()) 
return false; 
else 
return true; 

} 
?> 

Inoltre, creare un file di indice come di seguito:

<?php 
require 'Send_Mail.php'; 
$to = "[email protected]"; 
$subject = "Test Mail Subject"; 
$body = "Hi<br/>Test Mail<br/>Amazon SES"; // HTML tags 
Send_Mail($to,$subject,$body); 
?> 

Si prega di notare che se si ha accesso solo sandbox di SES, l'indirizzo di posta elettronica del destinatario ha anche bisogno di essere verificata. oppure potresti verificare il tuo dominio. fammi sapere se funziona.

+0

fare clic qui per ottenere [class.php.mailer] (http://www.johnboy.com/blog/sending-email-with-amazon-ses-smtp-and-phpmailer) – Mark

Problemi correlati