我想通过PHP邮件程序使用Gmail SMTP服务器发送电子邮件.
这是我的代码
<?php
require_once('class.phpmailer.php');
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->CharSet="UTF-8";
$mail->SMTPSecure = 'tls';
$mail->Host = 'smtp.gmail.com';
$mail->Port = 587;
$mail->Username = 'MyUsername@gmail.com';
$mail->Password = 'valid password';
$mail->SMTPAuth = true;
$mail->From = 'MyUsername@gmail.com';
$mail->FromName = 'Mohammad Masoudian';
$mail->AddAddress('anotherValidGmail@gmail.com');
$mail->AddReplyTo('phoenixd110@gmail.com', 'Information');
$mail->IsHTML(true);
$mail->Subject = "PHPMailer Test Subject via Sendmail, basic";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
$mail->Body = "Hello";
if(!$mail->Send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{ …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用phpMailer通过电子邮件向用户发送确认消息.我的代码是这样的:
<?php
include("class.phpmailer.php");
include("class.smtp.php");
$mail = new PHPMailer();
$mail->IsSMTP(); // set mailer to use SMTP
$mail->Host = "ssl://smtp.gmail.com"; // specify main and backup server
$mail->Port = 465; // set the port to use
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "sender@gmail.com"; // your SMTP username or your gmail username
$mail->Password = "mypasswrord"; // your SMTP password or your gmail password
$from = "webmaster@example.com"; // Reply to this email
$to="receiver@yahoo.com"; // Recipients email ID
$name="Jersey Name"; // Recipient's …Run Code Online (Sandbox Code Playgroud) 我收到以下错误:身份验证凭据无效。
我已经仔细检查了用户名(访问密钥 ID)和密码(秘密令牌)一百万次。我仔细检查了发送到服务器的 base64,它是正确的。用户具有正确的访问权限。允许来自 EC2 服务器的所有出站流量。SELinux 被禁用。我已经转义了特殊字符,尝试了不同的凭据。尝试使用具有更多访问权限的用户。
我正在将 PHPMailer 与 AWS SES 一起使用。
这是代码:
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'tls';
$mail->SMTPDebug = 4;
$mail->setFrom('braydenrhancock@gmail.com', 'Sender Name');
$mail->addAddress('braydenrhancock@gmail.com', 'Recipient Name');
$mail->Username = 'AKIAINH6PZ2UQKDK2BTA';
$mail->Password = 'GvMMa7R3fAXZGacl3gyfA86J0RxJLO7FQte9vrof';
$mail->Host = 'email-smtp.us-east-1.amazonaws.com';
$mail->Subject = 'Amazon SES test (SMTP interface accessed using PHP)';
$mail->Body = '<h1>Email Test</h1>';
$mail->Port = 587;
$mail->isHTML(true);
$mail->AltBody = "Email Test\r\nThis email was sent through the
Amazon SES SMTP interface using the PHPMailer class.";
if(!$mail->send()) { …Run Code Online (Sandbox Code Playgroud) 我在一个网站上工作,其中有一个表单,用于使用 PHPMailer 通过 gmail 发送电子邮件。
我已经正确设置了所有内容,因为它可以在我的 AWS EC2 服务器上运行。但是,当我在 GoDaddy 托管计划上使用完全相同的设置时,它不起作用(是的,我更改了“要求”路径)。
我收到此错误:
邮件程序错误:SMTP connect() 失败。
这是我的代码:
$mail = new PHPMailer;
$mail->SMTPDebug = 0;
$mail->isSMTP();
$mail->Host = "smtp.gmail.com";
$mail->SMTPAuth = true;
$mail->Username = "**********@gmail.com";
$mail->Password = "*************";
$mail->SMTPSecure = "tls";
$mail->Port = 587;
$mail->setFrom("**********@gmail.com", "Red's Mailer");
$mail->addAddress("*********@shaw.ca", "Name");
$mail->isHTML = true;
$mail->Subject = "New Submission From " . $name;
$mail->Body = $html_msg;
$mail->AltBody = $alt_msg;
Run Code Online (Sandbox Code Playgroud)
关于这个问题的任何想法?