$from = "someonelse@example.com";
$headers = "From:" . $from;
echo mail ("borutflis1@gmail.com" ,"testmailfunction" , "Oj",$headers);
Run Code Online (Sandbox Code Playgroud)
我在用PHP发送电子邮件时遇到问题.我收到一个错误:SMTP server response: 530 SMTP authentication is required.
我的印象是你可以发送没有SMTP的电子邮件来验证.我知道这封邮件可能会被过滤掉,但现在这并不重要.
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25
; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = someonelse@example.com
Run Code Online (Sandbox Code Playgroud)
这是php.ini文件中的设置.我该如何设置SMTP?是否有任何SMTP服务器不需要验证或我必须自己设置服务器?
您好我正在尝试 在我的Codeigniter应用程序中使用GitHUB中的PHPMailer库.
我下载了代码并在我的application\library文件夹中解压缩.所以我有一个名为vendor的文件夹,里面有PHPMailer的源代码.
现在我创建了一个名为的文件Bizmailer_Controller.php.
<?php defined('BASEPATH') OR exit('No direct script access allowed');
/**
*
*/
class Bizmailer_Controller extends CI_Controller
{
public function __construct()
{
parent::__construct();
require "vendor\phpmailer\phpmailer\PHPMailerAutoload";
$this->Bizmailer = new PHPMailer();
//Set the required config parameters
$this->Bizmailer->isSMTP(); // Set mailer to use SMTP
$this->Bizmailer->Host = 'smtp1.example.com;smtp2.example.com'; // Specify main and backup SMTP servers
$this->Bizmailer->SMTPAuth = true; // Enable SMTP authentication
$this->Bizmailer->Username = 'user@example.com'; // SMTP username
$this->Bizmailer->Password = 'secret'; // SMTP password …Run Code Online (Sandbox Code Playgroud) 我知道有很多关于这个问题的线索,但我不能让它工作,我已经尝试了一切!phpmailer下载中没有autoload.php,我被卡住了.
请帮助,即使我已经链接了所需的文件,这个错误"类'phpmailer'找不到"仍然出现.Xampp正在运行.所有邮件文件都在PHPMailer文件夹中(其中包含文件夹src /,其中包含我链接的那5个文件).提前致谢!
<!--Contact Starts-->
<div class="container contactform center">
<h2 class="text-center wowload fadeInUp"></h2>
<div class="row wowload fadeInLeftBig">
<div class="col-sm-6 col-sm-offset-3 col-xs-12">
<form method="post" action="index.php">
<input type="text" placeholder="Nombre" name="nombre" required>
<input type="email" placeholder="Email" name="email" required>
<input type="text" placeholder="Móvil" name="movil" required>
<textarea rows="5" placeholder="Mensaje" name="mensaje" required></textarea>
<button class="btn btn-danger" type="submit" name="sendBtn"><i class="fa fa-paper-plane"></i> Send</button>
</form>
</div>
</div>
</div>
</div>
<!--Contact Ends-->
<?php
if(isset($_POST["sendBtn"])){
require "PHPMailer/src/PHPMailer.php";
require "PHPMailer/src/OAuth.php";
require "PHPMailer/src/SMTP.php";
require "PHPMailer/src/POP3.php";
require "PHPMailer/src/Exception.php";
//Create a new PHPMailer instance
$mail = new PHPMailer(); …Run Code Online (Sandbox Code Playgroud) 错误:致命错误:未捕获错误:在C:\ xampp\htdocs\php-mailer\index.php中找不到类'PHPMailer':4堆栈跟踪:在C:\ xampp\htdocs\php-中抛出#0 {main}第4行的邮件程序\ index.php
我的PHP代码在这里:
require("src/PHPMailer.php");
require("src/Exception.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "gmail id"; // SMTP username
$mail->Password = "mypassword"; // SMTP password
$mail->From = "opensourcesivaprakash@gmail.com";
$mail->FromName = "Mailer";
$mail->AddAddress("siva.sing.sivan@gmail.com", "Josh Adams");
$mail->AddAddress("sp"); // name is optional
//$mail->AddReplyTo("opensourcesivaprakash@gmail.com", "Information");
$mail->WordWrap = 50; // set word wrap to 50 characters
//$mail->AddAttachment("/var/tmp/file.tar.gz"); // add attachments
//$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // optional name
$mail->IsHTML(true); // set email format to HTML
$mail->Subject …Run Code Online (Sandbox Code Playgroud)