我在apache中有一个需要使用sendmail.cf的Web应用程序(bugzilla).当它尝试使用sendmail时,我收到错误:
/etc/mail/sendmail.cf:第0行:无法打开:权限被拒绝
Web应用程序在组"apache"中
sendmail的权限如下:
-rw-r - r-- 1 root root 58624 2008-03-29 05:27 sendmail.cf
sendmail.cf的权限必须是什么才能被apache访问,但仍然足够安全以锁定其他人.
我正在开发一个必须发送电子邮件的PHP脚本.但我的mail()函数不起作用.我知道我必须以某种方式配置php.ini并且可能是别的但我不知道究竟是什么以及如何.顺便说一句,我安装了sendmail.有任何想法吗?非常感谢.这是我的代码.
error_reporting(E_ALL);
$to = 'name@gmail.com';
$subject = 'subject';
$message = 'text';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=windows-1251' . "\r\n";
$headers .= 'To: user <user@example.com>' . "\r\n";
$headers .= 'From: server <server@example.com>' . "\r\n";
mail($to, $subject, $message, $headers);
Run Code Online (Sandbox Code Playgroud)
在我放的php.ini中 sendmail_path ="/usr/sbin/sendmail"
PS.我使用Ubuntu
伙计们,我收到了mail.log文件
Apr 29 16:12:05 IT02 sendmail[7660]: My unqualified host name (IT02) unknown; sleeping for retry
Apr 29 16:13:05 IT02 sendmail[7660]: unable to qualify my own domain name (IT02) -- using short name
Apr 29 …Run Code Online (Sandbox Code Playgroud) #!/usr/bin/python
import smtplib
sender = 'from@fromdomain.com'
receivers = ['to@todomain.com']
message = """From: From Person <from@fromdomain.com>
To: To Person <TEST@yahoo.com>
Subject: SMTP e-mail test
This is a test e-mail message.
"""
try:
smtpObj = smtplib.SMTP('localhost')
smtpObj.sendmail(sender, receivers, message)
print "Successfully sent email"
except SMTPException:
print "Error: unable to send email"
Run Code Online (Sandbox Code Playgroud)
即使我导入了所有内容,我仍然会遇到以下错误.我正在使用Linux,缺少什么?
File "email.py", line 3, in <module>
import smtplib
File "/usr/lib/python2.7/smtplib.py", line 46, in <module>
import email.utils
File "/home/email.py", line 19, in <module>
except SMTPException:
Run Code Online (Sandbox Code Playgroud) 我正在用Python编程.我已经有一个函数发送带有消息和附件的电子邮件....我唯一的问题是我希望消息是HTML,但我的不尊重.....
这是我正在使用的功能
def enviarCorreo(fromaddr, toaddr, text, file):
msg = MIMEMultipart('mixed')
msg['From'] = fromaddr
msg['To'] = toaddr
msg['Subject'] = 'asunto'
msg.attach(MIMEText(text))
#adjunto
adjunto = MIMEBase('application', "octet-stream")
adjunto.set_payload(open(file, "rb").read())
encode_base64(adjunto)
anexo = os.path.basename(file)
adjunto.add_header('Content-Disposition', 'attachment; filename= "%s"' % anexo)
msg.attach(adjunto)
#enviar
server = smtplib.SMTP('localhost')
server.set_debuglevel(1)
server.sendmail(fromaddr, toaddr, msg.as_string())
server.quit()
return
Run Code Online (Sandbox Code Playgroud)
我希望你能告诉我要改变什么或添加什么,所以我发送的消息可能是HTML ....
我正在使用"MIXED"Multipart,因为HTML消息将包含一些不会附加但会成为消息的一部分的图像.....
我有代码
<?php
$strMailTo = "An Address";
$strSubject = "Plan for Today";
$strBody = "Today is" + date("l");
mail ($strMailTo, $strSubject, $strBody);
?>
Run Code Online (Sandbox Code Playgroud)
但是当我尝试在这种状态下发送它时,它只是在体内输出0.但是,如果我取出'date("l")它可以正常文本,所以我知道问题在哪里,而不是如何解决它.有人能指出我正确的方向吗?
我正在尝试发送带有图片的电子邮件; 我的电子邮件正文是:
<?php
$message = <<< email
<img src="http://planet-earth.bogus.us/icons/secret.pictures.gif">
Dear {$email},
email;
?>
Run Code Online (Sandbox Code Playgroud)
当我收到电子邮件时,我看不到图片.相反,我明白了<img src="http://planet-earth.bogus.us/icons/secret.pictures.gif">.我知道这是因为<<<电子邮件; 如何使用<<<电子邮件显示图片而不是代码?
UPDATE
我正在使用zend-framework.我的代码看起来像这样:
<?php
$mail = new Zend_Mail();
$mail->setFrom('admin@mysite.com', 'My site');
$mail->addTo($recoveryaccount->username);
$mail->setSubject("Mysite");
include "_email_recover_password.phtml";
$mail->setBodyText($message);
$mail->send();
?>
_include "_email_recover_password.pthml"
<?php
$message = <<< email
<img src="http://picturelocation.picture.gif">
Dear {$account->getUsername()},
Somebody has requested that the password associated with this account be
reset. If you initiated this request, click the below link to complete the process:
http://www.example.com/{$account->getRecovery()}
Thank you!
Mysite
Questions? Contact us at admin@mysite.com …Run Code Online (Sandbox Code Playgroud) 我在Joomla JUtility :: sendMail函数中遇到了一个问题
Joomla文档中提到的函数参数是这样的
问题是我无法设置fromemail(发件人电子邮件).当我设置发件人电子邮件并重播电子邮件时.邮件中显示的电子邮件重播是来自joomla admin config email的邮件.当我将其他电子邮件设置为重播或发件人电子邮件时,每次使用来自joomla admin config的电子邮件时,它都没有正确使用.
我得到了谷歌的一个参考几乎相同,但我试过这不起作用.
我正在使用Joomla 1.7
我试过了
$your_email //can be array but here string one email
$your_name //name i will work fine
$user_email //admin email
$subject //subject
//last two argument is reply to and replay name Its showing inside mail but click on replay it will admin config email.
JUtility::sendMail($your_email, $your_name, $user_email, $subject, $fcontent,1,NULL,NULL,NULL,$your_email,$your_name);
Run Code Online (Sandbox Code Playgroud)
任何帮助将不胜感激..
我想发送带有多个附件的电子邮件给多个接收者/多个CC接收者/ BCC接收者以及可能包含图像的格式化html内容男孩.
怎么做?
请建议.
我发送消息到无效的电子邮件地址,但我没有任何异常.它的工作就像一切都很好,并且在调试器中它显示一切正常.
private MailService() {
Properties props = new Properties();
props.put("mail.transport.protocol", "smtps");
props.put("mail.smtps.host", HOST);
props.put("mail.smtps.auth", "true");
props.put("mail.smtp.from", FROM);
props.put("mail.smtps.quitwait", "false");
mailSession = Session.getDefaultInstance(props);
mailSession.setDebug(true);
}
public static void sendMessage(String recipient, String subject,
String message) throws MessagingException {
if (mailService == null) {
mailService = new MailService();
}
MimeMessage mimeMessage = new MimeMessage(mailSession);
mimeMessage.setFrom(new InternetAddress(FROM));
mimeMessage.setSender(new InternetAddress(FROM));
mimeMessage.setSubject(subject);
mimeMessage.setContent(message, "text/plain");
mimeMessage.addRecipient(Message.RecipientType.TO, new InternetAddress(recipient));
Transport transport = mailSession.getTransport("smtps");
transport.connect(HOST, PORT, USER, PASSWORD);
transport.sendMessage(mimeMessage,
mimeMessage.getRecipients(Message.RecipientType.TO));
transport.close();
}
Run Code Online (Sandbox Code Playgroud)
我尝试了不同的电子邮件地址,并且尽管它没有抛出异常.我错了什么?
我做的是这样的:
echo "TEST MAIL" | mail -s "subject" "SOME@MAIL.COM"
Run Code Online (Sandbox Code Playgroud)
它送好了!但我必须在shell脚本中验证邮件是否已发送.
我找不到某种方法来验证邮件是否已发送.
编辑:
我唯一的验证是邮件应用程序中的返回值是否为0
if [ "$?" = "0" ]; then
echo "Mail enviado a: $destinatarios"
else
echo "Mail NO enviado a: $destinatarios"
fi
Run Code Online (Sandbox Code Playgroud) sendmail ×10
php ×4
email ×3
java ×2
linux ×2
python ×2
apache ×1
bash ×1
html ×1
image ×1
jakarta-mail ×1
joomla ×1
mime-message ×1
mime-types ×1
transport ×1