PHPMailer を使用してメールを送信しています。電子メールの差出人アドレスがMe! [myuser@gmail.com]
ではなくとして表示されることを除いて、うまく機能しますMe! [myemail@comcast.net]
。メールの差出人メール アドレスを設定するにはどうすればよいですか?
<?php
require_once ('class.phpmailer.php');
$email='myemail@comcast.net';
$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';