2013-10-02 3 views
1

Я использую PHPMailer для отправки электронной почты. Отлично работает, кроме адреса электронной почты От адреса отображается как Me! [[email protected]] вместо Me! [[email protected]]. Как установить адрес электронной почты электронной почты?Настройка из электронной почты на phpmailer

<?php 
    require_once ('class.phpmailer.php'); 
    $email='[email protected]'; 


    $mail = new PHPMailer; 

    $mail->isSMTP();          // Set mailer to use SMTP 

    $mail->Host  = "smtp.gmail.com"; 
    $mail->Port  = 587; //Maybe 465 instead? SSL only? 
    $mail->Username = "myusername"; 
    $mail->Password = "mypassword"; 


    $mail->SMTPAuth = true;        // Enable SMTP authentication 
    $mail->SMTPSecure = 'tls';       // Enable encryption, 'ssl' also accepted 

    $mail->From = $email; 
    $mail->FromName = 'Me!'; 
    $mail->addAddress($email, 'Josh Adams'); // Add a recipient 
    $mail->addReplyTo($email, 'Information'); 
    $mail->addCC($email); 
    $mail->addBCC($email); 

    $mail->WordWrap = 50;         // Set word wrap to 50 characters 
    $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'; 

    if(!$mail->send()) { 
     echo 'Message could not be sent.'; 
     echo 'Mailer Error: ' . $mail->ErrorInfo; 
     exit; 
    } 

    echo 'Message has been sent'; 
+0

Можете ли вы показать нам получили код заголовка источника электронной почты? И описать, какая часть вас беспокоит. –

+3

Если что-то совсем недавно изменилось, неизменяемый адрес «от» преднамерен - он предотвращает спуфинг: [http://stackoverflow.com/questions/3871577/change-sender-address-when-sending-mail-through-gmail- in-c-sharp] (http://stackoverflow.com/questions/3871577/change-sender-address-when-sending-mail-through-gmail-in-c-sharp) –

+0

@KristenJukowski. Я уверен, что ты прав. – user1032531

ответ

2

Вполне вероятно, что Кристен прямо в комментариях, однако вы можете попробовать редактирования файла class.phpmailer.php и изменения настроек там.

// The From email address for the message. 
// @type string 

    public $From = '[email protected]'; 

// The From name of the message. 
// @type string 

    public $FromName = 'Root User'; 

// The Sender email (Return-Path) of the message. 
// If not empty, will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode. 
// @type string 

    public $Sender = ''; 

Смежные вопросы