无论php.ini设置如何发送电子邮件

时间:2014-05-03 11:24:28

标签: javascript php jquery email

我的主机存在一些实际问题,因为他们没有为电子邮件发送设置php.ini 现在我的应用需要发送带有令牌代码的电子邮件等。我只与少数用户合作,他们的电子邮件地址在他们的登录数据旁边受到保护。

sendmail_from为空,只是为了更好地了解php.ini中的域名与实际域名的名称是否相同

只有MySQL和FTP访问参数。可能我无法访问php.ini,对吧? (我不确定这里缺乏知识,请原谅我)

在使用XAMPP的localhost上我可以轻松发送电子邮件,因为我可以根据需要在本地配置php.ini。

有没有办法发送电子邮件(可能不会发送电子邮件给那些不太好的电子邮件)只需按一下按钮,但无视php.ini包含的内容好像我无法访问php.ini?

我的应用程序主要基于Javascript / JQuery。我主要使用PHP隐藏敏感信息,处理登录会话和cookie。我是PHP的新手。

提前感谢您提供任何建议!

3 个答案:

答案 0 :(得分:2)

PHPmailer现在在github上https://github.com/Synchro/PHPMailer它被许多需要安装在系统上但没有安装电子邮件库的应用程序使用。它使用tcp / ip套接字建立连接,并为您处理低级协议。

答案 1 :(得分:2)

您可以尝试使用PHPMailer之类的内容。根据他们的github:

  

许多开源项目使用:Drupal,SugarCRM,Yii,Joomla!和   更多

这是一个邮件类,您可以使用它代替mail() - 允许您配置它而不更改php.ini

如果您可以使用sendmail,则可以执行以下操作:

<?php
require '../PHPMailerAutoload.php';

//Create a new PHPMailer instance
$mail = new PHPMailer();
// Set PHPMailer to use the sendmail transport
$mail->isSendmail();
//Set who the message is to be sent from
$mail->setFrom('from@example.com', 'First Last');
//Set an alternative reply-to address
$mail->addReplyTo('replyto@example.com', 'First Last');
//Set who the message is to be sent to
$mail->addAddress('whoto@example.com', 'John Doe');
//Set the subject line
$mail->Subject = 'PHPMailer sendmail test';
//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
//Replace the plain text body with one created manually
$mail->AltBody = 'This is a plain-text message body';
//Attach an image file
$mail->addAttachment('images/phpmailer_mini.png');

//send the message, check for errors
if (!$mail->send()) {
    echo "Mailer Error: " . $mail->ErrorInfo;
} else {
    echo "Message sent!";
}

否则您将需要一个可以与之配合使用的SMTP服务器。

答案 2 :(得分:1)

您的邮件服务器似乎存在问题。所以不要研究太多。为什么不应该继续使用gmail smtp,因为您的应用程序处于开发模式,您现在可以使用gmail smtp而不会停止工作。

http://lifehacker.com/111166/how-to-use-gmail-as-your-smtp-server

我更喜欢这样做:)